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

Hi All, I've seen a few posts here and there regarding this, but haven't come to a full solution yet. I have the below code grabbing a URL that has worked great before with HTTP but has since been changed to HTTPS and have a need to still access it this way. I have the latest version of OpenSSL and have install various other packages but nothing seems to be working in conjunction with mechanize. Comes back with the error: Error GETing https://randomurl.com: Can't connect to randomurl:443 (Bad hostname) at script.pl Any thoughts?
#!/usr/bin/perl use strict; use WWW::Mechanize; use IO::Socket::SSL; my $url = 'https://randomurl.com'; my $mech = WWW::Mechanize->new; $mech->credentials( 'username' => 'password' ); $mech->get( $url);

Replies are listed 'Best First'.
Re: Mechanize not working with HTTPS
by stevieb (Canon) on Jun 20, 2012 at 00:23 UTC
      Yeah I've added those packages and tried other flavors of having them grab the https url, but I keep getting the same issue when using mechanize. Is there something specific that may need to be done using the IO::Socket::HTTPS with mechanize to get them to play nicely with each other?

        Yeah I've added those packages and tried other flavors of having them grab the https url, but I keep getting the same issue when using mechanize.

        "bad hostname" is a DNS issue, nothing really you can do from perl

        Try  lwp-request -UuSsEed https://google.com/ if that doesn't work, nothing can work

Re: Mechanize not working with HTTPS
by Anonymous Monk on Jun 20, 2012 at 02:31 UTC
      Ignore the bad hostname error. If I just put the IP in, it just comes up w/the same GET error, but doesn't say bad hostname. Just that it can't connect on 443
Re: Mechanize not working with HTTPS
by zentara (Cardinal) on Jun 20, 2012 at 09:32 UTC
Re: Mechanize not working with HTTPS
by ddunleavy2 (Initiate) on Jun 20, 2012 at 15:59 UTC
    I have these modules installed and I can get a https url. Not sure which one(s) allow me to do it. I have problems posting but that's in another thread ;)
    perl check_perl_lib.pl Any::Moose -- 0.18 Archive::Zip -- 1.30 Attribute::Handlers -- 0.93 CPAN -- 1.9800 Carp -- 1.25 Class::Load -- 0.19 Class::Singleton -- 1.4 Compress::Raw::Bzip2 -- 2.052 Compress::Raw::Zlib -- 2.054 Config::General -- 2.50 Cwd -- 3.33 DBD::Oracle -- 1.42 DBD::SQLite -- 1.35 DBM::Deep -- 2.0006 Data::Dumper -- 2.131 Data::OptList -- 0.107 Date::Manip -- 6.31 DateTime -- 0.74 DateTime::Format::DateManip -- 0.04 DateTime::Locale -- 0.45 DateTime::TimeZone -- 1.46 Devel::PPPort -- 3.20 Digest::SHA -- 5.71 Dist::CheckConflicts -- 0.02 Encode::Locale -- 1.03 Expect -- 1.21 ExtUtils::CBuilder -- 0.280205 ExtUtils::MakeMaker -- 6.62 ExtUtils::ParseXS -- 3.15 File::HomeDir -- 0.99 File::Listing -- 6.04 File::Path -- 2.08 File::Which -- 1.09 Getopt::Attribute -- 2.101700 GnuPG::Interface -- 0.44 HTTP::Cookies -- 6.01 HTTP::Daemon -- 6.01 HTTP::Date -- 6.02 HTTP::Message -- 6.03 HTTP::Negotiate -- 6.01 IO::Compress -- ??? IO::Tty -- 1.10 IPC::Run3 -- 0.045 JSON -- 2.53 JSON::XS -- 2.32 LWP -- 6.04 LWP::MediaTypes -- 6.02 List::MoreUtils -- 0.33 Mail::Sendmail -- 0.79 Math::BigInt -- 1.997 Math::Round -- 0.06 Module::Implementation -- 0.06 Module::Runtime -- 0.013 Mouse -- 0.97 Net -- ??? Net::HTTP -- 6.03 Net::SMTP::SSL -- 1.01 Net::Telnet -- 3.03 Package::DeprecationManager -- 0.13 Package::Stash -- 0.33 Package::Stash::XS -- 0.25 Params::Util -- 1.07 Params::Validate -- 1.06 Perl -- 5.8.8 Sub::Exporter -- 0.982 Sub::Install -- 0.926 Sub::Uplevel -- 0.24 Test::Deep -- 0.109 Test::Exception -- 0.31 Test::Fatal -- 0.010 Test::Harness -- 3.23 Test::Inter -- 1.03 Test::NoWarnings -- 1.04 Test::Output -- 1.01 Test::Requires -- 0.06 Test::Script -- 1.07 Test::Simple -- 0.98 Test::Tester -- 0.108 Test::Warn -- 0.24 Tie::DBI -- 1.05 Time::Format -- 1.11 Tree::DAG_Node -- 1.06 Try::Tiny -- 0.11 WWW::Mechanize -- 1.72 WWW::RobotRules -- 6.02 XML::XPath -- 1.13 YAML::Syck -- 1.20 common::sense -- 3.6 parent -- 0.225
      That's a little broad...lol. Can you narrow that down? Whats the code your using to connect?