]> git.proxmox.com Git - pve-cluster.git/commitdiff
use PVE::Certificate to read fingerprint
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 6 Nov 2019 12:36:08 +0000 (13:36 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 8 Nov 2019 11:45:44 +0000 (12:45 +0100)
instead of duplicating the whole "read certificate from file" code that
we already have in pve-common.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
data/PVE/Cluster.pm
debian/control

index 596d87e46c97450dde53ad5885981e1bf9a65239..155a639e454a873ac7280ff637645e9e62ae2101 100644 (file)
@@ -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);
 }
 
 
index b3410d2c7b6ed4cf8e73c45914524d895ce2bb1b..28d0798fd2233c30d8b0c42aff1613f705eced31 100644 (file)
@@ -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,