在curl PHP脚本中,我们通过curl_setopt CURLOPT_HTTPHEADER 选项添加标题。
In curl PHP script, we add the headers by the curl_setopt CURLOPT_HTTPHEADER option. It works fine with HTTP request like search.yahoo but I tried it with the HTTPS request it doesn't work.
我已经禁用SSL对等验证,通过设置 CURLOPT_SSL_VERIFYPEER 选项为false。有办法实现吗?
I have disable SSL peer verification by setting CURLOPT_SSL_VERIFYPEER option to false. Is there way to implement it?
推荐答案首先,您需要下载CA证书与您的浏览器,并将其保存为X .509。这将使您能够接受CA颁发的所有证书。然后使用以下CURL选项:
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有不同的选项,你可以先尝试0以便检查CN检查,如果它工作然后尝试2。
CURLOPT_VERIFYHOST has different options, you can try 0 first in order to aviod CN check, and if it works then try with 2.
希望它有帮助。
更多推荐
如何添加自定义标题到https请求curl PHP脚本?
发布评论