6

Modern browsers support HTTPS proxies that can be connected to via a PAC file (see https://www.igvita.com/2012/06/25/spdy-and-secure-proxy-support-in-google-chrome/ if you're not familiar).

I'm trying to replicate the same thing and connect to such a proxy via php CURL, but I'm simply getting a blank response, no headers or content.

My code is as follows:

$url = "http://checkip.dyndns.com";
$proxy = "proxy.domain.com:443";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL , 1);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'test:test');
curl_setopt($ch, CURLOPT_PROXYTYPE, "CURLPROXY_HTTP");
$response = curl_exec($ch);
curl_close($ch);

echo $response;

Any ideas?

  • 1
    please check http://stackoverflow.com/questions/15445285/how-can-i-connect-to-a-tor-hidden-service-using-curl-in-php – mim. Sep 09 '15 at 23:37
  • Its not a socks5 proxy, so I dont think this will work. The proxy servers use squid with nghttpx (https://nghttp2.org/documentation/nghttpx-howto.html#http-2-proxy-mode) to accept https connections over spdy protocol –  Sep 10 '15 at 03:15
  • Seems there is no http2 (or spdy) support in curl, so I guess doing this is currently impossible: https://github.com/bagder/curl/blob/master/docs/ROADMAP.md :( –  Sep 10 '15 at 03:39
  • Look again, there is http2 support in curl since a year or so. – Daniel Stenberg Sep 10 '15 at 14:06

2 Answers2

0

If anyone is interested, the solution to this is to use spdycat instead of curl: https://github.com/tatsuhiro-t/spdylay

0

There's no support for connecting to a proxy with HTTPS with curl yet. There is a work-in-progress branch in git though: https://github.com/bagder/curl/tree/HTTPS-proxy

We will appreciate help to get that in shape to merge.

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222