ZF-1318: HTTPS connection through Proxy

Description

I try to make HTTPS connection through Proxy with Zend_Http_Client and Zend_Http_Client_Adapter_Proxy. but always get expection "Unable to read response, or response is empty". Proxy has been verified no problem. After some debugging, I found that the only message returned from the proxy is "Connection: close".

p.s. make direct HTTPS connection works fine with Zend_Http_Client.

Comments

Hi,

Is this proxy open? Can you pass some example code and if possible the address of a proxy I can test on?

TIA,

here are some code you can take a look. the proxy used is Tor, I donot have a open to public proxy server , but you can easily install Tor on almost any platform.


<?php

require_once 'Zend/Http/Client.php';
require_once('Zend/Http/CookieJar.php');
require_once 'Zend/Db.php';

session_start();

$client = new Zend_Http_Client();
$client->setConfig(
    array(
    'maxredirects'      => 5,
    'useragent'          => 'Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3',
    'timeout'           => 30,
    'keepalive'      => true,
    'adapter'    => 'Zend_Http_Client_Adapter_Proxy',
    //'ssltransport' => 'ssl',
    'proxy_host' => 'localhost',
    'proxy_port' => 8118,
    )
);

$client->setUri('https://www.apache-ssl.org');
try {
   $response = $client->request();
} catch (Zend_Http_Client_Exception $ex) {
   // Report the exception to the user
   die('Client Excep'.$ex->getMessage());
} catch (Zend_Http_Exception $ex) {
    die('Http Excep'. $ex->getMessage());
}
echo $response->getBody();

?>

Hi,

I've done some research and I believe that in order to properly support tunneling of HTTPS connections, we need to properly implement the CONNECT method in the client.

This is a big change and thus cannot be applied on the main branch before 1.0 is released. Also, it would require some time to work on.

I will do my best to look into this, but I am not sure this will be supported soon.

OK then, thanks

Changed to 'new feature' - add proper support for HTTP CONNECT requests

Support was added in one of the latest revisions and should be available in SVN HEAD. I am still waiting for feedback (got none) to see if it properly works or not.

I have tested the ZF latest revision. It did not work, I'm getting following errors

Warning: stream_socket_enable_crypto() [streams.crypto]: this stream does not support SSL/crypto in /Applications/Zend/ZendStudio-5.5.0/bin/ZendFramework/library/Zend/Http/Client/Adapter/Proxy.php on line 194

above my last comment, the problem was because of I did not have openssl installed.

It works now!!!

Thanks!!!

No complaints yet - seems to be relatively well implemented. If any bugs appear they should be opened as new issues.