Refs #6202 - Add possibility to send a certificate
This commit is contained in:
parent
730b42e8e6
commit
d9b629ad31
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Copyright 2005-2015 CENTREON
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
|
@ -18,18 +18,19 @@
|
|||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# As a special exception, the copyright holders of this program give CENTREON
|
||||
# permission to link this program with independent modules to produce an timeelapsedutable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting timeelapsedutable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# distribute the resulting timeelapsedutable under terms of CENTREON choice, provided that
|
||||
# CENTREON also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Author : Simon BOMM <sbomm@merethis.com>
|
||||
# Authors : Simon BOMM <sbomm@merethis.com>
|
||||
# Mathieu Cinquin <mcinquin@centreon.com>
|
||||
#
|
||||
# Based on De Bodt Lieven plugin
|
||||
####################################################################################
|
||||
|
@ -48,7 +49,7 @@ sub new {
|
|||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$self->{version} = '1.1';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
|
@ -64,6 +65,9 @@ sub new {
|
|||
"critical:s" => { name => 'critical' },
|
||||
"timeout:s" => { name => 'timeout', default => '3' },
|
||||
"ssl:s" => { name => 'ssl', },
|
||||
"cert-file:s" => { name => 'cert_file' },
|
||||
"cert-pwd:s" => { name => 'cert_pwd' },
|
||||
"cert-pkcs12" => { name => 'cert_pkcs12' },
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
@ -94,6 +98,10 @@ sub check_options {
|
|||
$self->{output}->add_option_msg(short_msg => "You need to set --username= and --password= options when --credentials is used");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if ((defined($self->{option_results}->{pkcs12})) && (!defined($self->{option_results}->{cert_file}) && !defined($self->{option_results}->{cert_pwd}))) {
|
||||
$self->{output}->add_option_msg(short_msg => "You need to set --cert-file= and --cert-pwd= options when --pkcs12 is used");
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
|
||||
sub run {
|
||||
|
@ -186,6 +194,18 @@ Threshold warning in seconds (Webpage response time)
|
|||
|
||||
Threshold critical in seconds (Webpage response time)
|
||||
|
||||
=item B<--cert-file>
|
||||
|
||||
Specify certificate to send to the webserver
|
||||
|
||||
=item B<--cert-pwd>
|
||||
|
||||
Specify certificate's password
|
||||
|
||||
=item B<--cert-pkcs12>
|
||||
|
||||
Specify type of certificate (PKCS12)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
###############################################################################
|
||||
# Copyright 2005-2013 MERETHIS
|
||||
# Copyright 2005-2015 CENTREON
|
||||
# Centreon is developped by : Julien Mathis and Romain Le Merlus under
|
||||
# GPL Licence 2.0.
|
||||
#
|
||||
|
@ -18,18 +18,19 @@
|
|||
# combined work based on this program. Thus, the terms and conditions of the GNU
|
||||
# General Public License cover the whole combination.
|
||||
#
|
||||
# As a special exception, the copyright holders of this program give MERETHIS
|
||||
# As a special exception, the copyright holders of this program give CENTREON
|
||||
# permission to link this program with independent modules to produce an timeelapsedutable,
|
||||
# regardless of the license terms of these independent modules, and to copy and
|
||||
# distribute the resulting timeelapsedutable under terms of MERETHIS choice, provided that
|
||||
# MERETHIS also meet, for each linked independent module, the terms and conditions
|
||||
# distribute the resulting timeelapsedutable under terms of CENTREON choice, provided that
|
||||
# CENTREON also meet, for each linked independent module, the terms and conditions
|
||||
# of the license of that module. An independent module is a module which is not
|
||||
# derived from this program. If you modify this program, you may extend this
|
||||
# exception to your version of the program, but you are not obliged to do so. If you
|
||||
# do not wish to do so, delete this exception statement from your version.
|
||||
#
|
||||
# For more information : contact@centreon.com
|
||||
# Author : Simon BOMM <sbomm@merethis.com>
|
||||
# Authors : Simon BOMM <sbomm@merethis.com>
|
||||
# Mathieu Cinquin <mcinqui@centreon.com>
|
||||
#
|
||||
# Based on De Bodt Lieven plugin
|
||||
####################################################################################
|
||||
|
@ -38,6 +39,7 @@ package centreon::plugins::httplib;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use LWP::UserAgent;
|
||||
use HTTP::Cookies;
|
||||
use URI;
|
||||
|
@ -125,6 +127,17 @@ sub connect {
|
|||
IO::Socket::SSL::set_default_context($context);
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{cert_pkcs12}) && $self->{option_results}->{cert_file} ne '' && $self->{option_results}->{cert_pwd} ne '') {
|
||||
use Net::SSL;
|
||||
$ENV{HTTPS_PKCS12_FILE} = $self->{option_results}->{cert_file};
|
||||
$ENV{HTTPS_PKCS12_PASSWORD} = $self->{option_results}->{cert_pwd};
|
||||
}
|
||||
|
||||
if (defined($self->{option_results}->{cert_file}) && !defined($self->{option_results}->{cert_pkcs12})) {
|
||||
use Net::SSL;
|
||||
$ENV{HTTPS_CERT_FILE} = $self->{option_results}->{cert_file};
|
||||
}
|
||||
|
||||
$response = $ua->request($req);
|
||||
|
||||
if ($response->is_success) {
|
||||
|
|
Loading…
Reference in New Issue