Hello Monks,
I feel like going mad.
I need a perl-script, doing a 'https-file-get' to a http proxy with proxy-authentication. So far so good:
#!/usr/local/bin/perl -w
use LWP::UserAgent;
use LWP::Debug qw(+);
$ENV{HTTPS_PROXY} = 'http://xxx.xxx.xxx.xxx:8080';
$ENV{HTTPS_PROXY_USERNAME} = 'myUsername';
$ENV{HTTPS_PROXY_PASSWORD} = 'myPassword';
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new'GET',"https://url.name.de/");
my $res = $ua->request($req);
print $res->content;
BUT:
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET https://freemail.web.de/
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::UserAgent::request: Simple response: Internal Server Error
is the result.
So it seems that the
Crypt::SSLeay does not work like it's mentionend in
perldoc Crypt::SSLeay. The proxy is not recognized by LWP.
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';
Use of the HTTPS_PROXY environment variable in this way is
similar to LWP::UserAgent->env_proxy() usage, but calling
that method will likely override or break the Crypt::SSLeay
support, so do not mix the two.
Basic auth credentials to the proxy server can be provided
this way:
# PROXY_BASIC_AUTH
$ENV{HTTPS_PROXY_USERNAME} = 'username';
$ENV{HTTPS_PROXY_PASSWORD} = 'password';
For an example of LWP scripting with Crypt::SSLeay native
proxy support, please see the source of the ./lwp-ssl-test
script in the Crypt::SSLeay distribution.
Also the
lwp-ssl-test does not recognize the proxy. And I can't use the LWP Proxy Supportliek this:
my $ua = new LWP::UserAgent;
$ua->proxy([qw( https http )], "$proxy_ip:$proxy_port");
... because my proxy needs a CONNECT which is not yet implemented in LWP.
Any help/hints are welcome.
Cheers
-----------------------------------
--the good, the bad and the physi--
-----------------------------------