php使用stream_socket_client() 报错

问答中心分类: PHPphp使用stream_socket_client() 报错
liubeia asked 3周 ago

stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

11 Answers
Best Answer
oneinstack 管理员 answered 2周 ago

最简单修复方法如下:

wget --no-check-certificate http://curl.haxx.se/ca/cacert.pem -O /usr/local/openssl/ssl/cert.pem

已经修复

oneinstack 管理员 answered 3周 ago

已经修复这个问题,谢谢反馈!

liubeia answered 3周 ago

是更新到最新版本就行了吗?  我最后google了一天才解决 原因是php没有加载ca证书 ,这个ca证书加载后之前我说的那个file_get_contents抓取不到https的问题也解决了.

oneinstack 管理员 answered 3周 ago

是的,可以尝试重新安装试试。

helaobibi answered 2周 ago

我用whmcs发邮件,打开debug模式,也是这个报错,环境是nginx+mysql5.5+php5.6+ionCube  是7月6日安装的环境,报错信息是:2017-07-07 01:41:49 Connection: opening to ssl://hwsmtp.exmail.qq.com:465, timeout=300, options=array ( ) 2017-07-07 01:41:49 Connection: Failed to connect to server. Error number 2. “Error notice: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed 2017-07-07 01:41:49 Connection: Failed to connect to server. Error number 2. “Error notice: stream_socket_client(): Failed to enable crypto 2017-07-07 01:41:49 Connection: Failed to connect to server. Error number 2. “Error notice: stream_socket_client(): unable to connect to ssl://hwsmtp.exmail.qq.com:465 (Unknown error) 2017-07-07 01:41:49 SMTP ERROR: Failed to connect to server: (0) 2017-07-07 01:41:49 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

liubeia answered 2周 ago

原因是phpopenssl没有加载ca证书 , 去下载个ca证书然后添加进去即可

helaobibi answered 2周 ago

我是新手比较水,求方法

liubeia answered 2周 ago

cd /usr/local/php/etc
wget http://curl.haxx.se/ca/cacert.pem
vi php.ini
#openssl.cafile=” //大约在2018行删除# 并替换下面这个 前提是下载路径和我的一样 
 openssl.cafile=/usr/local/php/etc/cacert.pem
 

helaobibi answered 2周 ago

谢谢大佬,搞定了,非常感谢

liubeia answered 2周 ago

客气了, 我也是这问题最后google了一天才解决 , 能解决就好

oneinstack 管理员 answered 2周 ago

very nice!