Sending the xml header and script body – HP Remote Insight Lights-Out Edition II Board User Manual

Page 131

Advertising
background image

Scripting, command line, and utility options 131

$ctx = Net::SSLeay::CTX_new() or die_now("ERROR: Failed to create

SSL_CTX $! ");

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

$!");

Net::SSLeay::set_fd($ssl, fileno(S));

Net::SSLeay::connect($ssl) and die_if_ssl_error("ERROR: ssl connect");

print STDERR 'SSL Connected ';

print 'Using Cipher: ' . Net::SSLeay::get_cipher($ssl) if $debug;

print STDERR "\n\n";

return $ssl;

}

Sending the XML header and script body

After the connection is established, the first line of script sent must be an XML document header, which
tells the device's HTTPS Web server that the following content is an XML script. The header must match the
header used in the example exactly. After the header has been completely sent, the remainder of the
script can be sent. In this example, the script is sent all at once. For example:

# usage: sendscript(host, script)

# sends the xmlscript script to host, returns reply

sub sendscript($$)

{

my $host = shift;

my $script = shift;

my ($ssl, $reply, $lastreply, $res, $n);

$ssl = openSSLconnection($host);

# write header

$n = Net::SSLeay::ssl_write_all($ssl, '<?xml version="1.0"?>'."\r\n");

rint "Wrote $n\n" if $debug;

# write script

$n = Net::SSLeay::ssl_write_all($ssl, $script);

print "Wrote $n\n$script\n" if $debug;

$reply = "";

$lastreply = "";

READLOOP:

while(1)

{

Advertising