From c92b771669e68a8b49906b8a0a68b533750567b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 6 Nov 2019 13:36:08 +0100 Subject: [PATCH] use PVE::Certificate to read fingerprint MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit instead of duplicating the whole "read certificate from file" code that we already have in pve-common. Signed-off-by: Fabian Grünbichler --- data/PVE/Cluster.pm | 23 ++--------------------- debian/control | 2 +- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm index 596d87e..155a639 100644 --- a/data/PVE/Cluster.pm +++ b/data/PVE/Cluster.pm @@ -17,6 +17,7 @@ use Socket; use Storable qw(dclone); use UUID; +use PVE::Certificate; use PVE::INotify; use PVE::IPCC; use PVE::JSONSchema; @@ -1681,26 +1682,6 @@ sub initialize_cert_cache { if defined($node) && !defined($cert_cache_nodes->{$node}); } -sub read_ssl_cert_fingerprint { - my ($cert_path) = @_; - - my $bio = Net::SSLeay::BIO_new_file($cert_path, 'r') - or die "unable to read '$cert_path' - $!\n"; - - my $cert = Net::SSLeay::PEM_read_bio_X509($bio); - Net::SSLeay::BIO_free($bio); - - die "unable to read certificate from '$cert_path'\n" if !$cert; - - my $fp = Net::SSLeay::X509_get_fingerprint($cert, 'sha256'); - Net::SSLeay::X509_free($cert); - - die "unable to get fingerprint for '$cert_path' - got empty value\n" - if !defined($fp) || $fp eq ''; - - return $fp; -} - sub get_node_fingerprint { my ($node) = @_; @@ -1709,7 +1690,7 @@ sub get_node_fingerprint { $cert_path = $custom_cert_path if -f $custom_cert_path; - return read_ssl_cert_fingerprint($cert_path); + return PVE::Certificate::get_certificate_fingerprint($cert_path); } diff --git a/debian/control b/debian/control index b3410d2..28d0798 100644 --- a/debian/control +++ b/debian/control @@ -34,7 +34,7 @@ Depends: corosync (>= 2.3.4-1), libfuse2 (>= 2.9.2-4), libglib2.0-0 (>= 2.42.1-1), libpve-apiclient-perl, - libpve-common-perl (>= 5.0-28), + libpve-common-perl (>= 6.0-7~), libqb0 (>= 0.17.1-1), librrds-perl, libsqlite3-0, -- 2.39.2