Get subject key identifier from certificate
<p>Is it possible to extract the <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2" rel="nofollow">subject key identificator</a> from an existing certificate with python? </p>

<p>I tried someting like:</p>

<pre><code>from OpenSSL.crypto import load_certificate, FILETYPE_PEM

cert_string='-----BEGIN CERTIFICATE--...'
certificate=load_certificate(FILETYPE_PEM, plain_cert)
subject=certificate.get_subject()
</code></pre>

<p>But it gives back the subject of the certificate. It seems like the certificate object doesn't offer functions for the subject key identifier. Are there other options?</p>

<p>The code that will extract subject key identifier:</p>

<pre><code>from cryptography import x509
from cryptography.hazmat.backends import default_backend

cert = x509.load_pem_x509_certificate(pem_data, default_backend())
ski = cert.extensions.get_extension_for_oid(x509.oid.ExtensionOID.SUBJECT_KEY_IDENTIFIER)
print(ski.value.digest)
</code></pre>

python cryptography certificate pyopenssl