EasyManua.ls Logo

HP Integrated Lights-Out

HP Integrated Lights-Out
410 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Perl Scripting 257
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))
{
$sin = sockaddr_in(443, $ip);
$ctx = Net::SSLeay::CTX_new() or die_now("ERROR:
Failed to create SSL_CTX $! ");
Net::SSLeay::set_fd($ssl, fileno(S));
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";
socket (S, &AF_INET, &SOCK_STREAM, 0) or die "ERROR:
socket: $!";
connect (S, $sin) or die "connect: $!";
Net::SSLeay::CTX_set_options($ctx,
&Net::SSLeay::OP_ALL);
die_if_ssl_error("ERROR: ssl ctx set options");
$ssl = Net::SSLeay::new($ctx) or die_now("ERROR:
Failed to create SSL $!");

Table of Contents

Related product manuals