Re: SSL acces through proxy: Unable to service this URL without parent cache

Josef Wolf <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
On Wed, Apr 30, 2008 at 09:14:19PM +0200, Josef Wolf wrote:

Are there really no ideas what goes wrong here?

> Hello,
> 
> when I try SSL access over a proxy, I get the following error message
> from the proxy:
> 
> 
>    Unable to service this URL without parent cache.Contact your system
>    administrator.
> 
> 
> Here is what I try to do:
> 
> 
>    #! /usr/bin/perl
>    
>    use strict;
>    use warnings;
>    
>    my $conf = {
>        proxy      => "http://proxy.domain.de:81",
>        proxy_user => "proxyuser",
>        proxy_pass => "proxysecret",
>        "ssl-authority-files" => "/etc/ssl/root.pem",
>    
>        noproxy    => "localhost,localdomain",
>        user       => "user",
>        pass       => "secret",
>    };
>    
>    {
>        use LWP::UserAgent;
>        use LWP::Debug("+", "+conns");
>        package EditSslAgent;
>    
>        { no strict; @ISA = qw(LWP::UserAgent); }
>    
>        sub get_basic_credentials {
>            my ($self, $realm, $uri, $isproxy) = @_;
>            my ($user, $pass);
>            my $myrealm = sprintf ("<%s://%s> %s",
>                                   $uri->scheme(),
>                                   $uri->host_port(),
>                                   $realm);
>    
>            print "request credentials $myrealm $isproxy\n";
>    
>            if ($isproxy) {
>                $user = $conf->{"proxy_user"};
>                $pass = $conf->{"proxy_pass"};
>            } else {
>                $user = $conf->{"user"};
>                $pass = $conf->{"pass"};
>            }
>    
>            return () unless defined $user && defined $pass;
>    
>            print "provide credentials for $user\n";
>    
>            return ($user, $pass);
>        }
>    }
>    
>    $ENV{HTTPS_DEBUG}   = 1;
>    $ENV{HTTPS_CA_FILE} = $conf->{"ssl-authority-files"};
>    $ENV{https_proxy}   = $conf->{proxy};
>    $ENV{http_proxy}    = $conf->{proxy};
>    $ENV{ftp_proxy}     = $conf->{proxy};
>    $ENV{wais_proxy}    = $conf->{proxy};
>    $ENV{gopher_proxy}  = $conf->{proxy};
>    $ENV{no_proxy}      = $conf->{noproxy};
>    
>    my $ua = new EditSslAgent (agent=>"Netscape/2.1");
>    $ua->env_proxy;
>    my $resp = $ua->get("https://google.de/foo/bar");
>    print $resp->as_string;
> 
> 
> And here is the debug output:
> 
> 
>    LWP::UserAgent::new: ()
>    LWP::UserAgent::proxy: https http://proxy.domain.de:81
>    LWP::UserAgent::proxy: gopher http://proxy.domain.de:81
>    LWP::UserAgent::proxy: http http://proxy.domain.de:81
>    LWP::UserAgent::proxy: ftp http://proxy.domain.de:81
>    LWP::UserAgent::proxy: wais http://proxy.domain.de:81
>    LWP::UserAgent::request: ()
>    LWP::UserAgent::send_request: GET https://google.de/foo/bar
>    LWP::UserAgent::_need_proxy: Proxied to http://proxy.domain.de:81
>    LWP::Protocol::http::request: ()
>    LWP::Protocol::collect: read 460 bytes
>    LWP::UserAgent::request: Simple response: Internal Server Error
>    HTTP/1.1 500 Server Error
>    Connection: close
>    Date: Mon, 24 Apr 2008 01:22:15 GMT
>    Server: NetCache appliance (NetApp/6.0.6)
>    Content-Length: 460
>    Content-Type: text/html
>    Client-Date: Mon, 24 Apr 2008 01:23:00 GMT
>    Client-Peer: 192.168.1.28:81
>    Client-Response-Num: 1
>    Title: 500 Server Error
>    
>    <HTML>
>    <HEAD><TITLE>500 Server Error</TITLE></HEAD>
>    <BODY>
>    <H1>Server Error</H1>
>    <H4>
>    The following error occurred:<P>
>    [code=PARENT_NEEDED] Unable to service this URL without parent cache.Contact your system administrator.
>    </H4>
>    <HR>
>    Please contact the administrator.
>    Generated by proxy in domain
>    <p>
>     <td><font face="Arial,Helvetica"><font size="-2"> F proxy
>      U: proxyuser IP: 192.168.1.12 https://google.de/foo/bar
>        </font></font></td>
>    </BODY>
>    </HTML>
> 
> 
> It looks like LWP does a GET request to the proxy instead of a
> CONNECT request.
> 
> Any ideas what is going wrong here?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.