PHP curl出现SSL certificate problem: self signed certificate in certificate chain

Use PHP curl https requests when error "SSL certificate problem: self signed certificate in certificate chain", this situation can not authenticate the client certificate root cause, the solution is as follows.

method one

Ignore certificate validation, add the following code to the curl method.

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);

Cons:  Each curl method should add the above method, a bit of trouble.

Method Two:

From curl official website, download the root certificate: cacert.pem  , then modify php.iniadded to the certificate, and restart the web service.

 

 

#在php.ini中加入
[SSL]
curl.cainfo = "D:\xampp\php\cacert.pem"
openssl.cafile = "${curl.cainfo}"

Guess you like

Origin www.cnblogs.com/kinwing/p/11105077.html