且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP通过代理连接到HTTPS站点

更新时间:2022-04-16 02:55:47

更新:
添加

curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);

它将阻止您的HTTP代理解析您的请求标头并采取更透明的行为 - 就像隧道一样。

It will prevent your HTTP proxy to parse your request headers and to act more transparently - like a tunnel.

初步回答,不感兴趣

您的代码看起来不错,我假设您检查了琐碎的问题,因此问题可能是SSL证书验证失败。如果证书是通过示例自签名的话就是这种情况。
尝试

Your code looks OK, and I assume you checked the trivial issues, so the problem is probably that the SSL certificate verification fails. It's the case if the certificate is self signed by example. Try

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

允许允许使用自签名证书的请求。

to allow a request that allows using a self signed certificate.