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

This code gives me the error message
Error GETing Can't connect to
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( " +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'.
by moritz (Cardinal) on Apr 26, 2014 at 13:26 UTC
    $ wget --2014-04-26 15:23:36-- +ecordSearch.jsp Resolving ( Connecting to (||:443... con +nected. OpenSSL: error:140773E8:SSL routines:SSL23_GET_SERVER_HELLO:reason(100 +0) Unable to establish SSL connection. $ curl 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;
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
by zentara (Archbishop) on Apr 26, 2014 at 14:46 UTC