Add possibility to specify ssl version refs #6199

This commit is contained in:
Kevin Duret 2015-03-12 11:54:23 +01:00
parent ba0d1e79ea
commit 44040e9573
5 changed files with 28 additions and 0 deletions

View File

@ -61,6 +61,7 @@ sub new {
"proxyurl:s" => { name => 'proxyurl' }, "proxyurl:s" => { name => 'proxyurl' },
"expected-string:s" => { name => 'expected_string' }, "expected-string:s" => { name => 'expected_string' },
"timeout:s" => { name => 'timeout', default => '3' }, "timeout:s" => { name => 'timeout', default => '3' },
"ssl:s" => { name => 'ssl', },
}); });
return $self; return $self;
} }
@ -158,6 +159,10 @@ Specify password for basic authentification (Mandatory if --credentials is speci
Threshold for HTTP timeout Threshold for HTTP timeout
=item B<--ssl>
Specify SSL version (example : 'sslv3', 'tlsv1'...)
=item B<--expected-string> =item B<--expected-string>
Specify String to check on the Webpage Specify String to check on the Webpage

View File

@ -67,6 +67,7 @@ sub new {
"expected-string:s" => { name => 'expected_string' }, "expected-string:s" => { name => 'expected_string' },
"header:s@" => { name => 'header' }, "header:s@" => { name => 'header' },
"timeout:s" => { name => 'timeout', default => 10 }, "timeout:s" => { name => 'timeout', default => 10 },
"ssl:s" => { name => 'ssl', },
"warning-numeric:s" => { name => 'warning_numeric' }, "warning-numeric:s" => { name => 'warning_numeric' },
"critical-numeric:s" => { name => 'critical_numeric' }, "critical-numeric:s" => { name => 'critical_numeric' },
@ -419,6 +420,10 @@ Specify password for basic authentification (Mandatory if --credentials is speci
Threshold for HTTP timeout (Default: 10) Threshold for HTTP timeout (Default: 10)
=item B<--ssl>
Specify SSL version (example : 'sslv3', 'tlsv1'...)
=item B<--header> =item B<--header>
Set HTTP headers (Multiple option) Set HTTP headers (Multiple option)

View File

@ -63,6 +63,7 @@ sub new {
"warning:s" => { name => 'warning' }, "warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' }, "critical:s" => { name => 'critical' },
"timeout:s" => { name => 'timeout', default => '3' }, "timeout:s" => { name => 'timeout', default => '3' },
"ssl:s" => { name => 'ssl', },
}); });
return $self; return $self;
} }
@ -173,6 +174,10 @@ Proxy URL if any
Threshold for HTTP timeout Threshold for HTTP timeout
=item B<--ssl>
Specify SSL version (example : 'sslv3', 'tlsv1'...)
=item B<--warning> =item B<--warning>
Threshold warning in seconds (Webpage response time) Threshold warning in seconds (Webpage response time)

View File

@ -67,6 +67,7 @@ sub new {
"expected-string:s" => { name => 'expected_string' }, "expected-string:s" => { name => 'expected_string' },
"header:s@" => { name => 'header' }, "header:s@" => { name => 'header' },
"timeout:s" => { name => 'timeout', default => 10 }, "timeout:s" => { name => 'timeout', default => 10 },
"ssl:s" => { name => 'ssl', },
"warning-numeric:s" => { name => 'warning_numeric' }, "warning-numeric:s" => { name => 'warning_numeric' },
"critical-numeric:s" => { name => 'critical_numeric' }, "critical-numeric:s" => { name => 'critical_numeric' },
@ -433,6 +434,10 @@ Specify password for basic authentification (Mandatory if --credentials is speci
Threshold for HTTP timeout (Default: 10) Threshold for HTTP timeout (Default: 10)
=item B<--ssl>
Specify SSL version (example : 'sslv3', 'tlsv1'...)
=item B<--header> =item B<--header>
Set HTTP headers (Multiple option) Set HTTP headers (Multiple option)

View File

@ -117,6 +117,14 @@ sub connect {
$ua->proxy(['http', 'https'], $self->{option_results}->{proxyurl}); $ua->proxy(['http', 'https'], $self->{option_results}->{proxyurl});
} }
if (defined($self->{option_results}->{ssl}) && $self->{option_results}->{ssl} ne '') {
use IO::Socket::SSL;
my $context = new IO::Socket::SSL::SSL_Context(
SSL_version => $self->{option_results}->{ssl},
);
IO::Socket::SSL::set_default_context($context);
}
$response = $ua->request($req); $response = $ua->request($req);
if ($response->is_success) { if ($response->is_success) {