举杯邀月

php网络请求报错:SSL operation failed with code 1.

摘要:安装Composer PHP Warning: copy();file_get_content、getimagesize请求网络地址报错:SSL operation failed with code 1.

报错信息

SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
1
2

解决方法

应该是CA证书验证失败造成的错误,下载个CA证书

wget http://curl.haxx.se/ca/cacert.pem
mv cacert.pem /usr/local/openssl/ssl/certs/cacert.pem
vim /usr/local/webserver/php/etc/php.ini
1
2
3

修改cafile路径,保存

[openssl]
; The location of a Certificate Authority (CA) file on the local filesystem
; to use when verifying the identity of SSL/TLS peers. Most users should
; not specify a value for this directive as PHP will attempt to use the
; OS-managed cert stores in its absence. If specified, this value may still
; be overridden on a per-stream basis via the "cafile" SSL stream context
; option.
;openssl.cafile=
openssl.cafile=/usr/local/openssl/ssl/certs/cacert.pem
1
2
3
4
5
6
7
8
9

作者:举杯邀月

出处: http://www.hug-code.cn/archives/5ff825a2241a4.html

2020-10-29 标签: php