]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Certificate.pm
tools: add fchownat syscall
[pve-common.git] / src / PVE / Certificate.pm
index 691e70b621b9a66017fb4a5dc5974c4750353e87..5ab920f24869a4aff5cc7920232445a961e5d62b 100644 (file)
@@ -78,6 +78,16 @@ PVE::JSONSchema::register_standard_option('pve-certificate-info', {
            format => 'pem-certificate',
            optional => 1,
        },
+       'public-key-type' => {
+           type => 'string',
+           description => 'Certificate\'s public key algorithm',
+           optional => 1,
+       },
+       'public-key-bits' => {
+           type => 'integer',
+           description => 'Certificate\'s public key size',
+           optional => 1,
+       },
     },
 });
 
@@ -260,6 +270,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;