我建议使用更广泛的加密库,例如具有X509证书功能和RSA加密的M2Crypto:
from M2Crypto import RSA, X509data = ssl_sock.getpeercert(1)# load the certificate into M2Crypto to manipulate itcert = X509.load_cert_string(data, X509.FORMAT_DER)pub_key = cert.get_pubkey()rsa_key = pub_key.get_rsa()cipher = rsa_key.public_encrypt('plaintext', RSA.pkcs1_padding)


