Opening an ssl connection – HP Remote Insight Lights-Out Edition II Board User Manual

Page 130

Advertising
background image

Scripting, command line, and utility options 130

print $client '<LOCFG version="2.21">' . "\r\n";

XML script modification

<!--

The bold line could be added for the return of properly formatted XML.

-->

<LOCFG version="2.21"/>

<RIBCL version="2.0">

<LOGIN USER_LOGIN="Adminname" PASSWORD = "password">

<!--

Add XML script here.

-->

</LOGIN>

</RIBCL>

</LOCFG>

Opening an SSL connection

Perl scripts must open an SSL connection to the device's HTTPS port, by default port 443. For example:

use Socket;

use Net::SSLeay qw(die_now die_if_ssl_error);

Net::SSLeay::load_error_strings();

Net::SSLeay::SSLeay_add_ssl_algorithms();

Net::SSLeay::randomize();

#

# opens an ssl connection to port 443 of the passed host

#

sub openSSLconnection($)

{

my $host = shift;

my ($ctx, $ssl, $sin, $ip, $nip);

if (not $ip = inet_aton($host))

{

print "$host is a DNS Name, performing lookup\n" if $debug;

$ip = gethostbyname($host) or die "ERROR: Host $hostname not

found.\n";

}

$nip = inet_ntoa($ip);

print STDERR "Connecting to $nip:443\n";

$sin = sockaddr_in(443, $ip);

socket (S, &AF_INET, &SOCK_STREAM, 0) or die "ERROR: socket: $!";

connect (S, $sin) or die "connect: $!";

Advertising