perlbaski has asked for the wisdom of the Perl Monks concerning the following question:
The above request works I getcurl -k -L -c cookie.txt -b cookie.txt --user administrator:done! -- +header "Content-Type:application/json" --header "Accept:application/j +son" https://10.244.204.25/api/types/names
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
Using LWP
This does not work I get '_msg' => 'Can\'t connect to 10.244.204.25:443 (certificate verify failed)',use warnings; use LWP::UserAgent; require HTTP::Cookies; my $ua = new LWP::UserAgent; $ua->agent('Mozilla/5.0'); $cookie_jar = HTTP::Cookies->new( file => 'cookies_lwp.txt', autosave => 1 +, ignore_discard => 1 ); # A cookie file is needed to store the secur +ity keys. $ua->cookie_jar($cookie_jar); $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0; $ua->default_header( "Accept" =>"application/json" ); $ua->default_header( "Content-Type" => "application/json"); my $netloc="10.244.204.25:443"; $ua->credentials( $netloc, 'Security Realm', 'administrator', 'done!') +; $ua->ssl_opts( verify_hostnames => 0 ,SSL_verify_mode => 0x00); my $req = new HTTP::Request('GET','https://10.244.204.25/api/types/nam +es'); my $res = $ua->request($req); print $res->code, "\n"; print $res->message; use Data::Dumper;
Doesnt $ua->ssl_opts( verify_hostnames => 0 ,SSL_verify_mode => 0x00); do the equivalent of curl -k which is to use insecure connection?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: LWP::UserAgent to ignore ssl certificate
by hazylife (Monk) on Mar 18, 2014 at 08:51 UTC | |
by perlbaski (Sexton) on Mar 18, 2014 at 20:04 UTC | |
Re: LWP::UserAgent to ignore ssl certificate
by Anonymous Monk on Mar 18, 2014 at 08:50 UTC | |
Re: LWP::UserAgent to ignore ssl certificate
by t_rex_joe (Sexton) on Mar 18, 2014 at 17:15 UTC | |
by perlbaski (Sexton) on Mar 18, 2014 at 20:09 UTC |