Esteemed monks,
I am running the following code on Linux to access https://google.co.uk via an internal proxy

#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use MIME::Base64; use Data::Dumper; my $url='https://google.co.uk'; $ENV{'HTTP_PROXY'}="http://websense:8080"; $ENV{'HTTPS_PROXY'}="http://websense:8080"; $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0; $ENV{HTTP_DEBUG}=1; my $ua=LWP::UserAgent->new('env_proxy'=>1,ssl_opts=>{verify_hostname=> +0}); $ua->env_proxy(); my $result=$ua->get($url); print("\n $@");

I get the following error:

Can't connect to google.co.uk:443 (Bad hostname) LWP::Protocol::https::Socket: Bad hostname 'google.co.uk' at /usr/loca +l/perl/lib/site_perl/LWP/Protocol/http.pm line 47.

If I run this script by changing the URL to 'http', i.e. insecure URL, I get the results from google.co.uk. Whereas 'httpS' returns the above error.

I have looked at various internet forums and can't figure out how to fix this. I have also tried to fetch https://google.co.uk from 'curl' command using the proxy and that returns a result. This clearly indicates there is something in my Perl script that I need to do.

Can you help?


In reply to LWP::UserAgent - Problem with httpS URL access via proxy by sumeetgrover

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.