error:14090086:SSL routines:ssl3_get_server_certificate

big_cat發表於2023-02-14
SSL handshake error: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

php curl 執行 https 請求時報錯如上

下載 cacert.pem

wget https://curl.haxx.se/ca/cacert.pem --no-check-certificat
mv cacert.pem /etc/pki/tls/certs/cacert.pem

修改 PHP OpenSSL 證照

php --ini 檢視 php.ini 的路徑

將原有的證照檔案替換為下載的 cacert.pem

[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=/etc/pki/tls/certs/ca-bundle.crt
openssl.cafile=/etc/pki/tls/certs/cacert.pem

重新執行即可~

相關文章