]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Certificate.pm
cert: add public key type and size to info
[pve-common.git] / src / PVE / Certificate.pm
index 691e70b621b9a66017fb4a5dc5974c4750353e87..65c5c8f6f2f5c2a1e73d7236b9229dc76b56bd1f 100644 (file)
@@ -260,6 +260,14 @@ sub get_certificate_info {
     $info->{san} = $parse_san->(Net::SSLeay::X509_get_subjectAltNames($cert));
     $info->{pem} = Net::SSLeay::PEM_get_string_X509($cert);
 
+    my $pub_key = eval { Net::SSLeay::X509_get_pubkey($cert) };
+    warn $@ if $@;
+    if ($pub_key) {
+       $info->{'public-key-type'} = Net::SSLeay::OBJ_nid2sn(Net::SSLeay::EVP_PKEY_id($pub_key));
+       $info->{'public-key-bits'} = Net::SSLeay::EVP_PKEY_bits($pub_key);
+       Net::SSLeay::EVP_PKEY_free($pub_key);
+    }
+
     Net::SSLeay::X509_free($cert);
 
     $cert_path =~ s!^.*/!!g;