Hello.
 
I am trying to get the libwww to work for SSL through proxy.  I applied Chris Hiner's patch(see attached) but was unsuccessful in getting it to work.  I am not much of a perl hacker but it seems to me that there is some problem around the part where the socket is supposed to turn into an SSL socket(see code portion below).  Reason being that I have put in a print in the connect subroutine in SSL.pm and the print statement did not show up.  It does show up for the case when no proxy is used though.  I have not been able to go much further as the only code I found in Crypt::SSLeay::Conn was:
 
package Crypt::SSLeay::Conn;
require Crypt::SSLeay;
1;     
 
There is also no new function in Crypt::SSLeay.  I really have no good feel of what's happening in the SSL portion.  Perhaps somebody else in this group can help.
 
BTW, my problem is the same as that posted by Fred Noz a while back, he didn't seem to get any solution either.
 
Thank you for your attention.
 
- Joo Geok
 
 
 
Code Portion
==========
 
    my $socket;
 
    my $proxy_request  = $request->clone;
    $proxy_request->method("CONNECT");
    my $proxy_protocol = LWP::Protocol::create('http');
 
    LWP::Debug::trace("Trying to CONNECT through the proxy server");
 
    my $proxy_response = $proxy_protocol->request($proxy_request, $proxy, $arg,$size, $timeout);
 
# Did we get through the proxy server?
    return $proxy_response unless($proxy_response->code == 200);
 
    $socket = $proxy_response->{client_socket};    
 
# Turn the socket into an SSL socket
    LWP::Debug::trace("Transmogrifying our socket");
    bless $socket, "Net::SSL";
    *$socket->{'ssl_ctx'} = Net::SSL::_default_context();
    my $ssl = Crypt::SSLeay::Conn->new(*$socket->{'ssl_ctx'}, $socket);
    if ($ssl->connect <= 0) {
        # XXX should obtain the real SSLeay error message
            LWP::Debug::trace("SSL error:".$ssl->connect);          
 
 
Trace Output
==========
 
LWP::UserAgent::new: ()
LWP::UserAgent::proxy: http http://proxy.krdl.org.sg:8080
LWP::UserAgent::proxy: https https://proxy.krdl.org.sg:8080
LWP::UserAgent::request: ()
LWP::UserAgent::simple_request: GET https://www.nodeworks.com
LWP::UserAgent::_need_proxy: Proxied to https://proxy.krdl.org.sg:8080
LWP::Protocol::https::request: ()
LWP::Protocol::https::request: Trying to CONNECT through the proxy server
LWP::Protocol::http::request: ()
LWP::Protocol::http::request: CONNECT www.nodeworks.com:443 HTTP/1.0
 

LWP::Protocol::http::request: reading response
LWP::Protocol::http::request: HTTP/1.0 200 Connection established
Proxy-Agent: NetCache 4.1R3
 
LWP::Protocol::http::request: HTTP/1.0 200 Connection established
LWP::Protocol::https::request: Transmogrifying our socket
LWP::Protocol::https::request: SSL error:0
Net::SSL: SSL negotiation failed at /usr/lib/perl5/site_perl/5.005/LWP/Protocol/
https.pm line 116
LWP::UserAgent::request: Simple response: Internal Server Error 
 

Reply via email to