Rob*_*bin 1 python cryptography certificate pyopenssl
是否可以使用 python 从现有证书中提取主题密钥标识符?
我试过类似的东西:
from OpenSSL.crypto import load_certificate, FILETYPE_PEM
cert_string='-----BEGIN CERTIFICATE--...'
certificate=load_certificate(FILETYPE_PEM, plain_cert)
subject=certificate.get_subject()
Run Code Online (Sandbox Code Playgroud)
但它返回证书的主题。似乎证书对象不提供主题密钥标识符的功能。还有其他选择吗?
将提取主题密钥标识符的代码:
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)
Run Code Online (Sandbox Code Playgroud)