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()等 ...
随机推荐
- oracle 临时表空间
环境: OS: Oracle Linux Server release 5.7 DB: Oracle Database 11g Enterprise Edition Release 11.2.0.3. ...
- 分享我常用的一些JS验证和函数
下面是我常用一些JS验证和函数,有一些验证我直接写到了对象的属性里面了,可以直接通过对象.方法来调用//浮点数除法运算 function fdiv(a, b, n) { if (n == undefi ...
- ASP.NET基础笔记
MSDN: ...
- 34.pad designer警告
1.Drill hole size is equal or larger than smallest pad size. Pad will be drilled away 原因:钻孔直径太大,直接把p ...
- Windows下安装Cygwin
1.去官网下载Cygwin http://www.cygwin.com/ 注意32位和64位的选择,完了直接点击exe文件开始安装. 2.安装 (1)“下一步”: (2)“Install form I ...
- CentOS安装Nexus(Maven私有库)详细配置及上传本地jar到私服
Nexus原理 Maven的原理就是将jar从远程中央仓库下载到PC磁盘的本地仓库,当本地仓库没有发现需要的jar就会去Maven默认的远程中央仓库Maven Central(由Apache维护)中寻 ...
- Windows窗体应用程序(非Console)使用libuv实现简单的异步WEB服务器
libuv是一个很强大的异步处理框架(严格意义上不能叫框架,其实就是一组异步函数库,当然框架这东西有各种各样的定义和理解_^...),最初的的目的是用于NODEJS的异步处理,不过因为它是一个独立的项 ...
- Netsharp快速入门(之19) 平台常用功能(插件操作)
作者:秋时 暗影 转载须说明出处 6.2 插件操作 6.2.1 停用/启用 1.在平台工具-插件管理,右击对应的插件可以使用启用和停用功能.插件停用后会把所有相关的页签.程序集.服务全部停 ...
- 802.11 wireless 七
802.11 wireless 7Wireless Fundamentals : End-to-End Discovering the NetworkGetting Connect Clients i ...
- sigaction 函数
本文主要参考<unix环境高级编程> sigaction函数的功能是检查或修改与指定信号相关联的处理动作(可同时两种操作). int sigaction(int signo,con ...