I am getting this error:
$VAR1 = 'Can’t connect to duece:52311 (certificate verify failed)
LWP::Protocol::https::Socket: SSL connect attempt failed error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed at /home/jmckinzie/perl5/lib/perl5/LWP/Protocol/http.pm line 48.
’;
The script is as follows… any ideas to bypass SSL in my lab environment?
Preformatted text
use strict;
use warnings;
use Data::Dumper;
use LWP::UserAgent;
use HTTP::Cookies;
#NOTE: some people have a connection error due to self signed cert. Next line is a workaround to importing the key into Perl.
#$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0;
##===================== Simplified IEM 9.0+ REST call in Perl
uses a user agent to deal communications.
uses a cookie for authentication
more help @ https://www.ibm.com/developerworks/mydeveloperworks/wikis/home/wiki/Tivoli+Endpoint+Manager/page/REST+API
#my server = ‘bigfix.company.com’;
my $server = ‘192.168.1.26’;
Setup the $REST object
my $REST= ({
HOST => “$server:52311”,
USER => ‘bigfix’,
PASS => ‘bigfix’,
URL => “https://:52311$server/api”,
REALM => “IBM Endpoint Manager Server”,
});
#create a user agent to talk with the web service on the BigFix server side.
$REST->{UA} = LWP::UserAgent->new( keep_alive => 0 );
#create a cookie to hold our authentication
$REST->{COOKIES} = HTTP::Cookies->new( file => “$REST->cookies.txt”, autosave => 1 );
#tell the UA about the cookie
$REST->{UA}->cookie_jar( $REST->{COOKIES} );
#put the credentials into the cookie (our logon transaction)
$REST->{UA}->credentials( $REST->{HOST}, $REST->{REALM}, $REST->{USER} => $REST->{PASS} );
#done with prep, now let’s use our $REST to make an API call.
#Set the REST resource that we want to be /sites more rest objects @ /help
$REST->{resource} = $REST->{URL} . ("/sites");
#set the REST method to GET - other methods are POST, DELETE and PUT
$REST->{request} = HTTP::Request->new( GET => $REST->{resource} );
#Now - Send the request through the User Agent and get the response
$REST->{response} = $REST->{UA}->request( $REST->{request} );
#Dump out just the response portion
print (Dumper($REST ->{response}->content));
OR, for greater learning experience: Dump out the entire $REST object - you can see the cookie info, the auth info, the results, the url call, all the headers and more.
“tem_rapi.pl” 56L, 2036C
indent preformatted text by 4 spaces