On Fri, Mar 18, 2005 at 06:39:38PM +0300, Evgeny Stepanov wrote:
> use strict;
> use LWP::UserAgent;
>
> my $ua = LWP::UserAgent->new;
> $ua->agent('Mozilla/5.0');
> $ua->proxy(['https', 'http', 'ftp'] => 'http://my.proxy.addr:3128');
> my $req = HTTP::Request->new(GET => 'https://some.secured.host/');
> my $res = $ua->request($req);
> if ($res->is_success) {
> print $res->as_string;
> }
> else {
> print "Failed: ", $res->status_line, "\n";
> }
>
> but it gives me
> Failed: 501 Not Implemented
> This piece of code works just fine without proxy defined, but i need
> proxy. As far as i understood, https through proxy is not implemented
> yet. Maybe you guys know another way to get it working with https
> through proxy?
Evgeny,
What you are trying to do is to initiate a 'GET' while most proxies
would expect method 'CONNECT'. With a GET the proxy would have to open
an SSL connection. With an end-to-end technology like SSL this is
pretty senseless. How should a proxy check the server cert or how
should the proxy send a client cert?
Sometimes it helps to read the docs. In Crypt::SSLeay it says
Crypt::SSLeay Proxy Support
For native Crypt::SSLeay proxy support of https requests, you
need to set an environment variable HTTPS_PROXY to your proxy
server & port, as in:
# PROXY SUPPORT
$ENV{HTTPS_PROXY} = 'http://proxy_hostname_or_ip:port';
$ENV{HTTPS_PROXY} = '127.0.0.1:8080';
ride or break the Crypt::SSLeay support, so do not mix the two.
Use of the HTTPS_PROXY environment variable in this way is
similar to LWP::UserAgent->env_proxy() usage, but calling that
method will likely over
And, voila, in the proxy logs you should see
==> /var/log/squid/access.log <==
1111195481.685 656 192.168..X.XX TCP_MISS/200 8934 CONNECT
some.secured.host:443 - DIRECT/XXXXXXXXX -
\rho