Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

LWP and HTTPS

by Gangabass (Vicar)
on Apr 26, 2014 at 13:06 UTC ( #1083930=perlquestion: print w/replies, xml ) Need Help??

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

This code gives me the error message
Error GETing https://www.kmcgov.in/KMCPortal/jsp/KMCDeathRecordSearch.jsp: Can't connect to www.kmcgov.in:443
:
ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; my $mech = WWW::Mechanize->new(); $mech->agent_alias("Windows IE 6"); $mech->ssl_opts( verify_hostnames => 0 ); $mech->get( "https://www.kmcgov.in/KMCPortal/jsp/KMCDeathRecordSearch. +jsp" );

What can I do to fix this issue? I have the latest versions of Net::SSLeay, Crypt::SSLeay, LWP, LWP::Protocol::https. Also I have installed Mozilla::CA, CACertOrg::CA

Replies are listed 'Best First'.
Re: LWP and HTTPS
by moritz (Cardinal) on Apr 26, 2014 at 13:26 UTC
    $ wget https://www.kmcgov.in/KMCPortal/jsp/KMCDeathRecordSearch.jsp --2014-04-26 15:23:36-- https://www.kmcgov.in/KMCPortal/jsp/KMCDeathR +ecordSearch.jsp Resolving www.kmcgov.in (www.kmcgov.in)... 210.212.29.170 Connecting to www.kmcgov.in (www.kmcgov.in)|210.212.29.170|:443... con +nected. OpenSSL: error:140773E8:SSL routines:SSL23_GET_SERVER_HELLO:reason(100 +0) Unable to establish SSL connection. $ curl https://www.kmcgov.in/KMCPortal/jsp/KMCDeathRecordSearch.jsp curl: (35) error:140773E8:SSL routines:SSL23_GET_SERVER_HELLO:reason(1 +000)

    I'd argue that either server's SSL setup is broken, or that you need a trust client certificate. Perl won't help you here.

      But why it's working in the browser? How I can tell LWP to ignore this error?
        Yet another broken SSL server which cannot do TLS1.0 or better. Browsers work around this kind of error by retrying with a downgraded SSL version.
        Recent versions of LWP (base of WWW::Mechanize) use IO::Socket::SSL/Net::SSLeay by default and you can simply enforce a specific SSL version like this:
        $mech->ssl_opts( SSL_version => 'SSLv3');
        I've tested it and it works with this broken server.
      I tried $ENV{HTTPS_VERSION} = 3; because curl -3 $URL is working but my Perl code still return same error :-(

        If you want to set up the environment, either do so outside your script, or at least, before the SSL modules are loaded:

        BEGIN { $ENV{ HTTPS_VERSION }= 3; }; use WWW::Mechanize;
Re: LWP and HTTPS
by Khen1950fx (Canon) on Apr 26, 2014 at 19:21 UTC
    FWIW, I've had a similar problem for the last 4 months with my smokers. The problem was with LWP::UserAgent and LWP::Protocol::https. I my case, I was using an external tar program. I solved the problem by doing:
    cpan> o conf init prefer_external_tar cpan> <prefer_external_tar> Use the external tar program instead of Archive::Tar? [no] cpan> o conf commit
    Next, reinstall Crypt::SSLeay
Re: LWP and HTTPS
by zentara (Archbishop) on Apr 26, 2014 at 14:46 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2020-06-04 18:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (35 votes). Check out past polls.

    Notices?