问题
In curl PHP script, we add the headers by the curl_setopt CURLOPT_HTTPHEADER option. It works fine with HTTP request like search.yahoo.com but I tried it with the HTTPS request it doesn't work.
I have disable SSL peer verification by setting CURLOPT_SSL_VERIFYPEER option to false. Is there way to implement it?
回答1:
here is a quick solution add curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); before curl_exec()
here $ch curl_init() object;
Do refer here for alternative solution
回答2:
first of all you need to download the CA certificate with your browser and save it as X.509. This will make you able to accept all certificates issued by the CA. Then use the following CURL options:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, "path_to_CA_certificate.crt");
CURLOPT_VERIFYHOST has different options, you can try 0 first in order to aviod CN check, and if it works then try with 2.
Hope it helps.
来源:https://stackoverflow.com/questions/24774221/how-to-add-the-custom-headers-to-https-requesting-curl-php-script