Login   Register  
PHP Classes
elePHPant
Icontem

HTTPS and proxy error 400

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      PHP HTTP protocol client  >  All threads  >  HTTPS and proxy error 400  >  (Un) Subscribe thread alerts  
Subject:HTTPS and proxy error 400
Summary:Sending https message to proxy causes "invalid Request"-error
Messages:11
Author:Thomas Gottfried
Date:2007-02-08 07:29:07
Update:2013-11-05 03:05:56
 
  1 - 10   11 - 11  

  1. HTTPS and proxy error 400   Reply   Report abuse  
Picture of Thomas Gottfried
Thomas Gottfried
2007-02-08 07:29:07
Hi,
I have a problem with my companies proxy-server when sending https message using HTTP Protocol Client. http messages working fine with this proxy. And https on leased line works a well (without proxy)

Proxy Server refuses to process message with error 400 "invalid Request":
This is output of test_http-script:

******************************************************************
# Opening connection to:

www.unterhaus-mainz.de

Connecting to www.unterhaus-mainz.de
Connecting to HTTP server IP 194.39.156.96...
Connected to 194.39.156.96
# Sending request for page:

/system_check.html

C GET https://www.unterhaus-mainz.de/system_check.html HTTP/1.1
C Host: www.unterhaus-mainz.de
C User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
C Pragma: nocache
C
# Request:

GET https://www.unterhaus-mainz.de/system_check.html HTTP/1.1

# Request headers:

Host: www.unterhaus-mainz.de
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Pragma: nocache

S HTTP/1.1 400 Bad Request
S Cache-Control: no-cache
S Pragma: no-cache
S Content-Type: text/html; charset=utf-8
S Proxy-Connection: close
S Connection: close
S Content-Length: 708
S
# Response status code:

400
# Response headers:

http/1.1 400 bad request:
cache-control: no-cache
pragma: no-cache
content-type: text/html; charset=utf-8
proxy-connection: close
connection: close
content-length: 708
******************************************************************

I'm pretty sure that proxy works with https messages as browser-messages are working fine. I've also managed to connect server through proxy using another piece of code - what is unfortuately not SSL coded:
******************************************************************
$host = "www.unterhaus-mainz.de:443";
$path = "/system_check.html";

$proxy = "194.39.156.96";
$proxy_port = "8080";

$fp = fsockopen($proxy, $proxy_port, $errno, $errstr);
fputs($fp, "POST ssl://$host$path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Referer: $referer\r\n");
fputs($fp, "Content-type: text/xml; charset=UTF8\r\n");
fputs($fp, "Cache-Control: no-cache\r\n");
fputs($fp, "Content-length: ". strlen($data_to_send) ."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data_to_send);

while(!feof($fp)) {
$res .= fgets($fp, 128);
}
fclose($fp);
******************************************************************

Could somebody help me?
It's really strange. Looks a little bit like proxy configuration is not fully http-complient ... or httpClient isn't.

thankx a lot in advance
thomas



  2. Re: HTTPS and proxy error 400   Reply   Report abuse  
Picture of Thomas Gottfried
Thomas Gottfried
2007-02-08 13:44:55 - In reply to message 1 from Thomas Gottfried
Hi all,
After posting this question, I've done some further investigation on the problem. So I found out, that this proxy I've used expects that first of all a CONNECT <host>:443 is sent.
This is what HTTP Protocol Client doesn't do.
http.php starts with a GET
Perhaps this helps
Cheers
thomas

  3. Re: HTTPS and proxy error 400   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2007-02-10 17:25:23 - In reply to message 2 from Thomas Gottfried
Yes, the problem is that when the proxy support was added, there was no way to start the SSL protocol on a connection already established.

It seems that is possible under PHP 5 but I need time to investigate whether it can be made to work reliably.

  4. Re: HTTPS and proxy error 400   Reply   Report abuse  
Picture of regsite
regsite
2008-01-29 20:49:11 - In reply to message 3 from Manuel Lemos
How to start the SSL protocol on a connection already established?
Not in your class, abstractedly..

  5. Re: HTTPS and proxy error 400   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2008-01-29 22:54:48 - In reply to message 4 from regsite
You need to call stream_socket_enable_crypto() .

  6. Re: HTTPS and proxy error 400   Reply   Report abuse  
Picture of regsite
regsite
2008-01-30 12:51:59 - In reply to message 5 from Manuel Lemos
Thank You! I will try it :)

  7. Re: HTTPS and proxy error 400   Reply   Report abuse  
Picture of regsite
regsite
2008-01-30 23:24:38 - In reply to message 6 from regsite
Megarespect man! I love you!!! =)
its work!
multithread fsockopen->socks->ssl now is reality!
Thank you!!!

  8. Re: HTTPS and proxy error 400   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2008-01-30 23:58:00 - In reply to message 7 from regsite
When I have time I will add support to SSL via proxies of SOCKS to the HTTP class.

  9. Re: HTTPS and proxy error 400   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2008-02-04 21:29:03 - In reply to message 7 from regsite
The HTTP class now supports setting SSL request over proxies if you are running PHP 5.1 or later. This avoids the HTTP 400 error that some reported before.

You may download the latest version to check it out.

  10. Re: HTTPS and proxy error 400   Reply   Report abuse  
Picture of Mirna Freitez Romero
Mirna Freitez Romero
2013-11-04 17:48:22 - In reply to message 7 from regsite
Hello.

I have the same problem.

Can you post the part of code with the solution (using stream_socket_enable_crypto)?

Thank you so much.

 
  1 - 10   11 - 11