crypto.load_certificate/获取public密钥加密
crypto.load_certificate / Get public key encryption
如何从 crypto.load_certificate 获得 public 密钥加密? (例如“RSA(2048 位”)。
我可以轻松获得 public 密钥,如下所示:
from OpenSSL import crypto
cert = crypto.load_certificate(crypto.FILETYPE_PEM, open("certificate.crt")).read()
pubKey = cert.get_pubkey()
但是我在文档中找不到任何关于加密的内容。有什么想法吗?
其实很简单:
from OpenSSL import crypto
cert = crypto.load_certificate(crypto.FILETYPE_PEM, open("certificate.crt")).read()
pubKey = cert.get_pubkey()
keySize = pubKey.bits()
if pubKey.type() == crypto.TYPE_RSA:
keyType = 'RSA'
elif pubKey.type() == crypto.TYPE_DSA:
keyType = 'DSA'
print(keyType + "-" + str(keySize))
如何从 crypto.load_certificate 获得 public 密钥加密? (例如“RSA(2048 位”)。
我可以轻松获得 public 密钥,如下所示:
from OpenSSL import crypto
cert = crypto.load_certificate(crypto.FILETYPE_PEM, open("certificate.crt")).read()
pubKey = cert.get_pubkey()
但是我在文档中找不到任何关于加密的内容。有什么想法吗?
其实很简单:
from OpenSSL import crypto
cert = crypto.load_certificate(crypto.FILETYPE_PEM, open("certificate.crt")).read()
pubKey = cert.get_pubkey()
keySize = pubKey.bits()
if pubKey.type() == crypto.TYPE_RSA:
keyType = 'RSA'
elif pubKey.type() == crypto.TYPE_DSA:
keyType = 'DSA'
print(keyType + "-" + str(keySize))