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

Edited by mrmax2000
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.