Peer certificate cannot be authenticated with known CA certificates.
I was trying to post to a webservice and was getting the 60 error code: Peer certificate cannot be authenticated with known CA certificates. .
The webservice I was trying to reach was over https.
The solution is very simple.
You need to set curl not to verify the ssl peer. You can do this by setting an option.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
The complete code to do a curl request:
<?php
$ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$string);
curl_setopt ($ch,CURLOPT_RETURNTRANSFER , 1 );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); curl_close($ch);
?>
To check the error codes use :
<?php
//gives the error code <a href="http://www.php.net/manual/en/function.curl-error.php
curl_error">http://www.php.net/manual/en/function.curl-error.php
curl_error</a>($ch); //or the code, usefull to let the script react on different codes
//<a href="http://www.php.net/manual/en/function.curl-errno.php
curl_errno">http://www.php.net/manual/en/function.curl-errno.php
curl_errno</a>($ch); //Gives the info about your latest request
curl_getinfo($ch);
?>
EDIT Allways check your SSL version. You can set it like this.
<?php
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
?>
For more http://www.php.net/manual/en/function.curl-setopt.php - See more at: http://dominiquedecooman.com/fr/solution-curl-webservice-curlesslcacert-60-peer-certificate-cannot-be-authenticated-known-ca#sthash.jaGjuyO3.dpuf
Peer certificate cannot be authenticated with known CA certificates.的更多相关文章
- git push 报错 "Peer certificate cannot be authenticated with known CA certificates"
使用git push -u origin master 命令向远程仓库提交代码时报错:Peer certificate cannot be authenticated with known CA ce ...
- Android进阶(二)https请求No peer certificate的解决方法.
在做Android客户端通过https协议访问12306,并爬取数据时,出现了如下错误: 其中有一条错误提示是 javax.net.ssl.SSLPeerUnverifiedException: No ...
- http请求No peer certificate的解决方法
不少同学在做HTTP请求新浪授权或新浪数据的时候会出现 javax.net.ssl.SSLPeerUnverifiedException: No peer certificate的异常.现给出解决方法 ...
- 解决升级PHP7.1后,发邮件时提示“fsockopen(): Peer certificate CN=`xxx.xx.com' did not match expected CN=`113.x.xx.98”
把项目环境升级到PHP7.1后,发现在不使用SSL时可以使用IP发邮件,可设置成SSL时就只能使用hostname发送,PHP提示的错误信息大致意思是说,IP与hostname无法通过SSL验证,修改 ...
- 基于OpenSSL自建CA和颁发SSL证书
关于SSL/TLS介绍见文章 SSL/TLS原理详解.关于证书授权中心CA以及数字证书等概念,请移步 OpenSSL 与 SSL 数字证书概念贴 . openssl是一个开源程序的套件.这个套件有三个 ...
- 在centos下部署docker内网私服
Docker内网私服:docker-registry with nginx & ssl on centos docker-registry既然也是软件应用,自然最简单的方法就是使用官方提供的已 ...
- 在CentOS 6上搭建私有的Docker Registry
在CentOS 6上搭建私有的Docker Registry v2Registry概念 :Registry是一个无状态的, 高可扩展的服务器端应用程序, 用于存储和分发Docker Image. 依赖 ...
- CentOS6.5Minimal安装Gitlab7.5
文章出处:http://www.restran.net/2015/04/09/gilab-centos-installation-note/ 在 CentOS 6.5 Minimal 系统环境下,用源 ...
- PHP中cURL错误号对照[转]
PHP cURL curl_errno 在php程序编写中,使用curl函数库的几率还是挺高的,如curl_init().curl_setopt().curl_exec().curl_errno()等 ...
随机推荐
- Redbean:入门(一) - 增删改查
<?php require_once 'rb.php'; $tableName = "link"; //链接数据库 R::setup("mysql:host=loc ...
- 52.ISE中的PLL时钟输入
在manaul mode中选择PLL PLL的输入时钟可以是全局时钟,也可以是普通IO引脚. 1.PLL的输入时钟是全局时钟的情况. pll_xx pll_xx ( .clkin ( clkin ), ...
- Linux C 文件与目录4 将缓冲区数据写入磁盘
将缓冲区数据写入磁盘 所谓缓冲区,是Linux系统对文件的一种处理方式.在对文件进行写操作时,并没有立即把数据写入到磁盘,而是把数据写入到缓冲区.如果需要把数据立即写入到磁盘,可以使用sync函数.用 ...
- Linux Shel高级技巧(目录)
Linux Shell高级技巧(一) http://www.cnblogs.com/stephen-liu74/archive/2011/12/22/2271167.html一.将输入信息转换为大写字 ...
- 64位Windows2003下如何正确发布VesnData.Net(VDN)
64位windows2003下发布VDN,按照正常的步骤会出现:试图加载格式不正确的程序. (异常来自 HRESULT:0x8007000B)的错误. 按照下面的步骤进行处理: 1.如果安装了64位F ...
- 容器适配器之stack
参见http://www.cplusplus.com/reference/stack/stack/ template<class T, class Container = deque<T& ...
- 搭建SpringMVC+MyBatis开发框架三
新增spingmvc.xml配置 在WEB-INF下新增spingmvc.xml,主要是配置spring扫描的包:  <?xml version="1.0" encodin ...
- Netsharp快速入门(之14) 销售管理(报表A 热销滞销品统计)
作者:秋时 杨昶 转载须说明出处 4.5 销售报表 4.5.1 热销滞销品统计 1.建立部件工作区,主部件选择报表.统计表,辅部件选择查询方案 2.设置报表模版.选择主部件,选择工具-报 ...
- Ionic 安装部署
Ionic 安装部署 准备工作 下载安装Node.js, JDK,Apache Ant,Android SDK:编辑器用WebStorm node jdk ant 均需要加进 环境变量path中 An ...
- 【BZOJ】【3856】Monster
又是一道水题…… 重点是分情况讨论: 首先我们很容易想到,如果a*k-b*(k+1)>0的话那么一定能磨死Monster. 但即使不满足这个条件,还有可能打死boss: 1.h-a<1也就 ...