lwp

Scripts broke after upgrading LWP “certificate verify failed”

瘦欲@ 提交于 2019-12-01 02:25:18
I have a lot of scripts, most of them based around WWW::Mechanize that scrape data off of misc hardware that is accessible via HTTPs. After upgrading most of my perl installation and its modules, all scripts using HTTPS:// broke because of "certificate verify failed" This is a result of the fact that the newer versions of LWP does a proper check on the certificate and dies if something doesn't match. In my case, the failed certificate authentication is expected due to the circumstances, so i needed to find a way of cleanly circumventing this check. Say I want to tell you something, and I don't

Why don't my LWP::UserAgent credentials work?

萝らか妹 提交于 2019-11-30 03:13:23
问题 I'm trying to access a protected file. Server is using digest authentication - which I can see from the printed out response. Here is the sample code: use LWP; use strict; my $url = 'http://somesite.com/aa/bb/cc.html'; my $username = 'scott'; my $password = 'tiger'; my $browser = LWP::UserAgent->new('Mozilla'); $browser->credentials("http://somesite.com:80","realm-name",$username=>$password); my $response=$browser->get($url); print $response->content; Name of the realm I got it from the popup

How can I make a JSON POST request with LWP?

旧时模样 提交于 2019-11-29 20:19:18
If you try to login at https://orbit.theplanet.com/Login.aspx?url=/Default.aspx (use any username/password combination), you can see that the login credentials are sent as a non-traditional set of POST data: just a lonesome JSON string and no normal key=value pair. Specifically, instead of: username=foo&password=bar or even something like: json={"username":"foo","password":"bar"} There's simply: {"username":"foo","password":"bar"} Is it possible to perform such a request with LWP or an alternative module? I am prepared to do so with IO::Socket but would prefer something more high-level if

How do I force LWP to use Crypt::SSLeay for HTTPS requests?

我只是一个虾纸丫 提交于 2019-11-29 07:01:30
My symptom is that I cannot use a proxy with HTTPS requests with LWP. This seems to be a common problem, and the hints on Google and even here all suggest a work-around for setting the HTTPS_PROXY environment variable for use by Crypt::SSLeay. My specific problem appears to be that LWP::Protocol::https is loading IO::Socket::SSL rather than Crypt::SSLeay. How can I force Crypt::SSLeay's use instead? My code: #!/usr/bin/perl use strict; use warnings; $ENV{HTTPS_PROXY} = 'http://10.0.3.1:3128'; use LWP::UserAgent; my $ua = LWP::UserAgent->new(); my $req = HTTP::Request->new('GET','https://www

Perl WWW::Mechanize (or LWP) get redirect url

百般思念 提交于 2019-11-29 06:52:52
So I am using WWW::Mechanize to crawl sites. It works great, except if I request a url such as: http://www.levi.com/ I am redirected to: http://us.levi.com/home/index.jsp And for my script I need to know that this redirect took place and what the url I was redirected to is. Is there anyway to detect this with WWW::Mechanize or LWP and then get the redirected url? Thanks! use strict; use warnings; use URI; use WWW::Mechanize; my $url = 'http://...'; my $mech = WWW::Mechanize->new(autocheck => 0); $mech->max_redirect(0); $mech->get($url); my $status = $mech->status(); if (($status >= 300) && (

How can I accept gzip-compressed content using LWP::UserAgent?

廉价感情. 提交于 2019-11-28 05:25:20
I am fetching some pages over the Web using Perl's LWP::UserAgent and would like to be as polite as possible. By default, LWP::UserAgent does not seamlessly handle compressed content via gzip. Is there an easy way to make it do so, to save everyone some bandwidth? LWP has this capability built in, thanks to HTTP::Message . But it's a bit hidden. First make sure you have Compress::Zlib installed so you can handle gzip . HTTP::Message::decodable() will output a list of allowed encodings based on the modules you have installed; in scalar context, this output takes the form a comma-delineated

How do I force LWP to use Crypt::SSLeay for HTTPS requests?

折月煮酒 提交于 2019-11-28 00:42:12
问题 My symptom is that I cannot use a proxy with HTTPS requests with LWP. This seems to be a common problem, and the hints on Google and even here all suggest a work-around for setting the HTTPS_PROXY environment variable for use by Crypt::SSLeay. My specific problem appears to be that LWP::Protocol::https is loading IO::Socket::SSL rather than Crypt::SSLeay. How can I force Crypt::SSLeay's use instead? My code: #!/usr/bin/perl use strict; use warnings; $ENV{HTTPS_PROXY} = 'http://10.0.3.1:3128';

Perl WWW::Mechanize (or LWP) get redirect url

蹲街弑〆低调 提交于 2019-11-28 00:33:09
问题 So I am using WWW::Mechanize to crawl sites. It works great, except if I request a url such as: http://www.levi.com/ I am redirected to: http://us.levi.com/home/index.jsp And for my script I need to know that this redirect took place and what the url I was redirected to is. Is there anyway to detect this with WWW::Mechanize or LWP and then get the redirected url? Thanks! 回答1: use strict; use warnings; use URI; use WWW::Mechanize; my $url = 'http://...'; my $mech = WWW::Mechanize->new

HTTPS Proxy and LWP::UserAgent

老子叫甜甜 提交于 2019-11-27 22:27:27
问题 I have read a number of threads on a number of sites and am still unable to make this work. I have a client machine (OSX) with OpenSSL 0.9.8r running perl 5.12.4, with LWP 6.0.4, updated Crypt::SSLeay, Net::SSL etc. I am trying to connect to an HTTPS site (https://github.com in the example) via a WinGate proxy that I have running on a Windows VM. Note that my actual application is attaching to an SSL webservice that I have no control over. From Firefox, pointed to the proxy everything is

How can I get LWP to validate SSL server certificates?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 17:36:09
How can I get LWP to verify that the certificate of the server I'm connecting to is signed by a trusted authority and issued to the correct host? As far as I can tell, it doesn't even check that the certificate claims to be for the hostname I'm connecting to. That seems like a major security hole (especially with the recent DNS vulnerabilities). Update: It turns out what I really wanted was HTTPS_CA_DIR , because I don't have a ca-bundle.crt. But HTTPS_CA_DIR=/usr/share/ca-certificates/ did the trick. I'm marking the answer as accepted anyway, because it was close enough. Update 2: It turns