cleanup Net::SSLeay error handling

X509_get_fingerprint does not die - it only returns undef in case of
errors (or segfaults if the $cert pointer is invalid).
This commit is contained in:
Fabian Grünbichler 2017-11-27 10:18:48 +01:00
parent adbda0b73e
commit 1d40f3c38c

View File

@ -258,11 +258,8 @@ my $verify_cert_callback = sub {
# check server certificate against cache of pinned FPs
# get fingerprint of server certificate
my $fp;
eval {
$fp = Net::SSLeay::X509_get_fingerprint($cert, 'sha256');
};
return 0 if $@ || !defined($fp) || $fp eq ''; # error
my $fp = Net::SSLeay::X509_get_fingerprint($cert, 'sha256');
return 0 !defined($fp) || $fp eq ''; # error
my $valid = $self->{cached_fingerprints}->{$fp};
return $valid if defined($valid); # return cached result