This article mainly introduces two methods for obtaining https requests from phpcurl. This article provides code examples that are set to not verify the certificate and host, and set a correct certificate, if you need it, you can refer to a colleague who reported the following error when using curl to initiate an https request: "SSL certificate problem, verify that the CA cert is OK. details: error: 14090086: SSL routines: SSL3_GET_SERVER_CERTIFICATE: certificate verify failed"
Obviously, a problem occurs during certificate verification.
Curl can be used in the following two ways:
Method 1: do not verify the certificate and host.
Before you execute curl_exec. Set option
The code is as follows:
$ Ch = curl_init ();
......
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, FALSE );
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, FALSE );
Method 2: Set a correct certificate.
The local ssl identification certificate is too old, resulting in incorrect link error ssl certificate.
We need to download the new ssl local discriminant file.
Http://curl.haxx.se/ca/cacert.pem
Put it in the program file directory
Add the following configuration for curl
The code is as follows:
Curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, true );;
Curl_setopt ($ ch, CURLOPT_CAINFO, dirname (_ FILE _). '/cacert. pem ');
Success
(My verification failed... Error message: SSL certificate problem, verify that the CA cert is OK. Details: error: 14090086: SSL routines: SSL3_GET_SERVER_CERTIFICATE: certificate verify failed)
If you are interested in this, you can refer to a great foreign article. Http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/