#!/usr/bin/perl use strict; use warnings; use Getopt::Std; use HTTP::Request; use LWP::UserAgent; use Net::SSLeay; use IO::Socket::SSL; my $options=(); getopts("ha:p:c:", \%main::options); if (defined $main::options{h}) { print "This program verifies SSL on a host\n"; print " -h see this message\n"; print " -a address of the host\n"; print " -p port (optional)\n"; print " -c path to SSL cert (optional)\n"; exit 0; } my $satisfied = 0; my $address = ""; my $port = 443; my $cert_filename = ""; if (defined $main::options{a}) { $satisfied += 1; $address = $main::options{a}; } if(($satisfied & 1) != 1) { print "Insufficient arguments. Check with -h what you missed\n"; exit -1; } if (defined $main::options{p}) { $port = $main::options{p}; } my $ua = ""; if (defined $main::options{c}) { $cert_filename = $main::options{c}; $ua = LWP::UserAgent->new( verify_hostname => 0, SSL_ca_file => "$cert_filename", ); } else { $ua = LWP::UserAgent->new(); } my $request = HTTP::Request->new(GET => "https://$address:$port/"); my $response = $ua->request($request); print $response->status_line . "\n";