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

转自:http://dominiquedecooman.com/fr/solution-curl-webservice-curlesslcacert-60-peer-certificate-cannot-be-authenticated-known-ca

Peer certificate cannot be authenticated with known CA certificates.的更多相关文章

  1. 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 ...

  2. Android进阶(二)https请求No peer certificate的解决方法.

    在做Android客户端通过https协议访问12306,并爬取数据时,出现了如下错误: 其中有一条错误提示是 javax.net.ssl.SSLPeerUnverifiedException: No ...

  3. http请求No peer certificate的解决方法

    不少同学在做HTTP请求新浪授权或新浪数据的时候会出现 javax.net.ssl.SSLPeerUnverifiedException: No peer certificate的异常.现给出解决方法 ...

  4. 解决升级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验证,修改 ...

  5. 基于OpenSSL自建CA和颁发SSL证书

    关于SSL/TLS介绍见文章 SSL/TLS原理详解.关于证书授权中心CA以及数字证书等概念,请移步 OpenSSL 与 SSL 数字证书概念贴 . openssl是一个开源程序的套件.这个套件有三个 ...

  6. 在centos下部署docker内网私服

    Docker内网私服:docker-registry with nginx & ssl on centos docker-registry既然也是软件应用,自然最简单的方法就是使用官方提供的已 ...

  7. 在CentOS 6上搭建私有的Docker Registry

    在CentOS 6上搭建私有的Docker Registry v2Registry概念 :Registry是一个无状态的, 高可扩展的服务器端应用程序, 用于存储和分发Docker Image. 依赖 ...

  8. CentOS6.5Minimal安装Gitlab7.5

    文章出处:http://www.restran.net/2015/04/09/gilab-centos-installation-note/ 在 CentOS 6.5 Minimal 系统环境下,用源 ...

  9. PHP中cURL错误号对照[转]

    PHP cURL curl_errno 在php程序编写中,使用curl函数库的几率还是挺高的,如curl_init().curl_setopt().curl_exec().curl_errno()等 ...

随机推荐

  1. hdu 3074 Multiply game

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=3074 Minimum Inversion Number Description Tired of pl ...

  2. 教你怎么安装RabbitMQ

    以下命令以root用户运行:#echo 'deb http://www.rabbitmq.com/debian/ testing main' >> /etc/apt/sources.lis ...

  3. Google工程师打造Remix OS系统 桌面版安卓下载

    三位前Google工程师打造的Remix OS系统终于来到了PC桌面上,现已可以下载尝鲜. Remix OS for PC基于Android-x86项目,由安卓5.1 Lollipop深度定制而来,不 ...

  4. Java BigDecimal大数字操作

    在java中提供了大数字的操作类,即java.math.BinInteger类和java.math.BigDecimal类.这两个类用于高精度计算,其中BigInteger类是针对大整数的处理类,而B ...

  5. oracle关于分区相关操作

    [sql] view plaincopy 1.查询当前用户下有哪些是分区表: SELECT * FROM USER_PART_TABLES; 2.查询当前用户下有哪些分区索引: SELECT * FR ...

  6. cacti install on ubuntu

    安装cacti需要的软件需要 nginx + php + mysql + rrdtool + cacti + snmp 1.nginx 安装配置 首先按照如下命令安装,明显是马虎不细心./config ...

  7. 学习JQuery的$.Ready()与OnLoad事件比较

    $(document).Ready()方法 VS OnLoad事件 VS $(window).load()方法接触JQuery一般最先学到的是何时启动事件.在曾经很长一段时间里,在页面载入后引发的事件 ...

  8. android 开发 drawerlayout出现退不回去的情况

    问题原因: id_framelayout2 写在 id_linearlayout2 的后面了: 注意记得写: android:layout_gravity="start" 正确: ...

  9. JavaScript 异常

    转载自:http://www.cnblogs.com/aqbyygyyga/archive/2011/10/29/2228824.html(排版格式修改了一下) 一.错误处理的重要性 以前,javas ...

  10. 剑指offer--面试题21

    题目:设计包含min函数的栈,pop(),push(),min()的时间复杂度均为O(1) 自己所写代码如下:(写‘栈’的代码还是有些不熟练!) #include <iostream> u ...