Jump to content

how to connected TLS through proxy in curl


mrmax2000

Recommended Posts

Hi,

I need help to use curl HTTPS in proxy. This is my code

$url = 'https://curl.haxx.se';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_ENCODING,'gzip,deflate'  );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY,'138.204.145.39:80');
curl_setopt($ch, CURLOPT_VERBOSE , true);
$verbose = fopen('e.txt', 'w+');
curl_setopt($ch, CURLOPT_STDERR, $verbose);
$r=curl_exec($ch);echo $r;

and this is verbose log

* Rebuilt URL to: https://curl.haxx.se/
*   Trying 138.204.145.39...
* TCP_NODELAY set
* Connected to 138.204.145.39 (138.204.145.39) port 80 (#0)
* Establish HTTP proxy tunnel to curl.haxx.se:443
> CONNECT curl.haxx.se:443 HTTP/1.1
Host: curl.haxx.se:443
Proxy-Connection: Keep-Alive

* Recv failure: Connection was reset
* Received HTTP code 0 from proxy after CONNECT
* Curl_http_done: called premature == 0
* Closing connection 0

the example above is return empty page with out error in verbose log error  Recv failure: Connection was reset

 

now we will change url from https://curl.haxx.se/ to https://www.google.com/ it's will run normal and get google page

with out any change in code only change url there are many sites not work in this way can any one help me to solve this issue

 

thank you

Link to comment
Share on other sites

You already got your answer:

The point I'm trying to make is that the proxy doesn't respond with proper HTTP in this case and thus it is broken - it doesn't help us much that it works fine with other hosts. There's nothing curl can do about a proxy that disconnects without even giving an error code. This is a proxy issue and you should ask the proxy admins about it.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.