cURL: https through a proxy

这一生的挚爱 提交于 2019-12-06 13:40:38

问题


I need to make a cURL request to a https URL, but I have to go through a proxy as well. Is there some problem with doing this? I have been having so much trouble doing this with curl and php, that I tried doing it with urllib2 in Python, only to find that urllib2 cannot POST to https when going through a proxy. I haven't been able to find any documentation to this effect with cURL, but I was wondering if anyone knew if this was an issue?


回答1:


I find testing with command-line curl a big help before moving to PHP/cURL.

For example, w/ command-line, unless you've configured certificates, you'll need -k switch. And to go through a proxy, it's the -x <proxyhost[:port]> switch.

I believe the -k equivalent is

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);

I believe the -x equivalent is

curl_setopt($curl, CURLOPT_PROXY, '<proxyhost[:port]>');

DISCLAIMER: I have not tested any of this. If you give more information about what you've tried, it might be helpful.




回答2:


No problem since the proxy server supports the CONNECT method.



来源:https://stackoverflow.com/questions/1308760/curl-https-through-a-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!