fix #3259: always free certificate file after reading it

This commit mirrors e3c4007bc94956962c03da8c6853415d2fdf057c in
pve-cluster. The fix there got lost with a refactoring for reusing the
code here in pve-common in c92b771669e68a8b49906b8a0a68b533750567b0

Tested by repeadetly reading https://$pve-node:8006/nodes on a
virtual testcluster.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
This commit is contained in:
Stoiko Ivanov 2021-02-11 19:19:47 +01:00 committed by Thomas Lamprecht
parent dc00c0529d
commit eb6262a6b7

View File

@ -199,10 +199,8 @@ my $read_certificate = sub {
or $ssl_die->("unable to read '$cert_path' - $!\n");
my $cert = Net::SSLeay::PEM_read_bio_X509($bio);
if (!$cert) {
Net::SSLeay::BIO_free($bio);
die "unable to read certificate from '$cert_path'\n";
}
Net::SSLeay::BIO_free($bio);
die "unable to read certificate from '$cert_path'\n" if !$cert;
return $cert;
};