+ 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) = @_;
# Global variables
my ($cert, $client);
eval { $client = IO::Socket::SSL->new(
my $client = IO::Socket::SSL->new(
PeerHost => $self->{option_results}->{hostname},
PeerPort => $self->{option_results}->{port},
$self->{option_results}->{servername} ? ( SSL_hostname => $self->{option_results}->{servername} ):(),
) };
if ($@) {
)
if (!defined($client)) {
$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}->exit()
}
#Retrieve Certificat
my $cert;
eval { $cert = $client->peer_certificate() };
if ($@) {
$self->{output}->output_add(severity => 'CRITICAL',
short_msg => sprintf("%s", $@));
$self->{output}->display();
$self->{output}->exit()
}