小编man*_*uri的帖子

如何使用Python2中的“加密”库从证书打印公钥?

我必须使用 Python2 中的加密库从 .pem 证书中提取公钥,但只能获取公钥对象。

在密码学文档中,我找到了这段代码

from cryptography.hazmat.primitives.asymmetric import rsa

pem_cert=open("/home/lab14/aes/fd.pem","rb").read()

cert = x509.load_pem_x509_certificate(pem_cert, default_backend())

public_key = cert.public_key()

print(public_key)
Run Code Online (Sandbox Code Playgroud)

但是当运行这个时,我得到公钥对象,但不是十六进制格式的实际密钥。

这是我得到的输出

<cryptography.hazmat.backends.openssl.rsa._RSAPublicKey object at 0x7f49e214d6d8>
Run Code Online (Sandbox Code Playgroud)

任何帮助都会有帮助和赞赏。谢谢

python cryptography certificate x509certificate

5
推荐指数
1
解决办法
4976
查看次数