+ Fix error message for x509 plugin

This commit is contained in:
garnier-quentin 2016-01-19 20:54:38 +01:00
parent 147b819856
commit dba1f7cb21
1 changed files with 5 additions and 7 deletions

View File

@ -79,27 +79,25 @@ sub run {
my ($self, %options) = @_; my ($self, %options) = @_;
# Global variables # Global variables
my ($cert, $client);
eval { $client = IO::Socket::SSL->new( my $client = IO::Socket::SSL->new(
PeerHost => $self->{option_results}->{hostname}, PeerHost => $self->{option_results}->{hostname},
PeerPort => $self->{option_results}->{port}, PeerPort => $self->{option_results}->{port},
$self->{option_results}->{servername} ? ( SSL_hostname => $self->{option_results}->{servername} ):(), $self->{option_results}->{servername} ? ( SSL_hostname => $self->{option_results}->{servername} ):(),
) }; )
if ($@) { if (!defined($client)) {
$self->{output}->output_add(severity => 'CRITICAL', $self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("%s", $@)); short_msg => "failed to accept or ssl handshake: $!,$SSL_ERROR");
$self->{output}->display(); $self->{output}->display();
$self->{output}->exit() $self->{output}->exit()
} }
#Retrieve Certificat #Retrieve Certificat
my $cert;
eval { $cert = $client->peer_certificate() }; eval { $cert = $client->peer_certificate() };
if ($@) { if ($@) {
$self->{output}->output_add(severity => 'CRITICAL', $self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("%s", $@)); short_msg => sprintf("%s", $@));
$self->{output}->display(); $self->{output}->display();
$self->{output}->exit() $self->{output}->exit()
} }