新年
快乐

垃圾堆中的精品

垃圾堆中的精品

宝塔 PHP7.2报错 failed loading cafile stream: `/etc/pki/tls/certs/ca-bundle.crt’

一个项目要做PHP自动化,结果开始一步就报错,真是头大。http请求类使用reactphp。运行样例直接报错。上代码

Error: Connection to tls://itnan.ren:443 failed during TLS handshake: failed loading cafile stream: `/etc/pki/tls/certs/ca-bundle.crt'

issue里面也没这报错啊,百度未果,严重怀疑人生了,然后直接使用代码测试

stream_socket_client("ssl://smtp.exmail.qq.com:465", $errno, $errstr, 120, STREAM_CLIENT_CONNECT);

保存运行

Warning: failed loading cafile stream: `/etc/pki/tls/certs/ca-bundle.crt' in /www/wwwroot/xxx/index.php on line 6

Warning: stream_socket_client(): Failed to enable crypto in /www/wwwroot/xxx/index.php on line 6

Warning: stream_socket_client(): unable to connect to ssl://smtp.exmail.qq.com:465 (Unknown error) in /www/wwwroot/xxx/index.php on line 6

查看宝塔php配置文件,一切正常,ca文件路径也对。网上无外乎两种办法:1.更新ca文件;2.设置权限。两种方法我试了,问题依旧,头发都要掉秃了…

随后切换成php5.6发现正常,检查后5.6的ca路径在php目录下,灵光乍现,难不成非得在php目录,然后将/etc/pki/tls/certs/ca-bundle.crt文件复制到/www/server/php/72/cacert/cacert.pem,修改php7.2配置文件

openssl.cafile=/www/server/php/72/cacert/cacert.pem
curl.cainfo = /www/server/php/72/cacert/cacert.pem

保存,重启PHP,刷新运行,完美解决,真是脑壳疼

评论回复

回到顶部