2

我想打印 SSL 公钥类型:

certificate = ssl.get_server_certificate(serverAddress)
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, certificate)
pk = x509.get_pubkey()
print("Certificate public key type : " + keyTypeToStr(pk.type()))
def keyTypeToStr(keyType):
    if keyType == OpenSSL.crypto.TYPE_RSA:
        return "RSA"
    elif keyType == OpenSSL.crypto.TYPE_DSA:
        return "DSA"
    #elif keyType == OpenSSL.crypto.TYPE_ECDSA: # this enum doesn't exist
    #   return "ECDSA"

    return "UNKNOW(" + str(keyType) + ")"

问题,它是一个数字...例如,我想打印“secp256r1”。我该怎么做?

4

0 回答 0