Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

"SSL negotiation failed" using WWW::Mechanize and Crypt::SSLeay on WinXP

by mickey (Acolyte)
on Mar 03, 2005 at 20:20 UTC ( [id://436357]=perlquestion: print w/replies, xml ) Need Help??

mickey has asked for the wisdom of the Perl Monks concerning the following question:

This is a pretty straight-forward question, so I'm hoping there might be an easy answer as well.

I'm trying to build a little screen-scraping script using WWW::Mechanize on WinXP. I need to access some HTTPS sites, so I've installed Crypt::SSLeay using ppm3. I'm using ActiveState Perl 5.6.1, and unfortunately getting a better version will be involve a great deal of trauma.

Here's a test script:

#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; my $url = 'https://www.helsinki.fi'; my $ua = LWP::UserAgent->new; my $response = $ua->get($url); $response->is_success or die "Failed to GET '$url': ",$response->status_line; print $response->as_string;

When I run this, the response is:

Failed to GET 'https://www.helsinki.fi/': 500 SSL negotiation failed: +at P:\Perl\bin/ssltest.bat line 15.

Does anyone know what problem this error message indicates?

I installed the necessary libraries, libeay32.dll and ssleay32.dll, in C:\Perl\bin during the ppm3 installation of Crypt::SSLeay. I don't have access to a compiler, so I can't compile OpenSSL myself.

Any and all advice is appreciated! Thanks very much.

Replies are listed 'Best First'.
Re: "SSL negotiation failed" using WWW::Mechanize and Crypt::SSLeay on WinXP
by talexb (Chancellor) on Mar 03, 2005 at 22:35 UTC

    Hmm .. the code I used for that is ..

    my $uri = URI->new("$webSite/LOGIN"); $uri->query_form( 'credential_0' => $user, 'credential_1' => $password, 'destination' => $webPage ); $res = $ua->get($uri); print "Status: " . $res->status_line . "\n"; die "Unable to log in: " . $res->status_line unless ( $res->status_line =~ /200 OK/ );
    Is there any way you can get more information on what failed? Can you run anything from the command line that works?

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: "SSL negotiation failed" using WWW::Mechanize and Crypt::SSLeay on WinXP
by inman (Curate) on Mar 04, 2005 at 09:38 UTC
    Do you use an HTTP proxy server by any chance to access the web from your location? You need an environment variable setting up to identify the proxy server.
    What is ssltest.bat? Have you converted your Perl script into a batch file? If the script is running as a batch file then you may not have the environment that you were expecting.

      OK, I've got some more information here. ssltest.bat is just the output of 'pl2bat ssltest.pl'. More importantly, I am going through a proxy server -- that had me stumped for a while.

      So what seems to be the issue now is that my proxy server isn't accepting my requests. Apparently there are two ways of doing this. The first is what LWP::UserAgent uses if I set $ua->proxy(...):

      GET https://www.secure.com HTTP/1.1

      and the second is what Crypt::SSLeay uses if I set $ENV{'HTTPS_PROXY'}:

      CONNECT https://www.secure.com HTTP/1.1

      In the first case, the proxy returns '400 Bad Request', and in the second it returns '403 Forbidden'. What that seems to mean is that the proxy doesn't know what to do with a GET request for a remote site, and while it does know what to do with a CONNECT request, it's configured not to allow them.

      Does that seem correct?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://436357]
Approved by virtualsue
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-03-29 13:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found