我试图使用Pythons OpenSSL库获取X.509证书的序列号。
如果我这样加载我的证书:
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_ASN1, cert)然后像这样打印序列号:
print x509.get_serial_number()看起来是这样的:
5.283978953499081e+37 如果我像这样把它转换成巫术:
'{0:x}'.format(int(5.283978953499081e+37))它返回以下内容:
27c092c344a6c2000000000000000000但是,使用命令行中的OpenSSL打印证书序列号会返回以下内容。
27:c0:92:c3:44:a6:c2:35:29:8f:d9:a2:fb:16:f9:b7为什么有一半的序列号被转换成零?
发布于 2016-09-02 12:43:16
'%x' % cert.get_serial_number()'%x' %格式字符串(如'{0:x}'.format(cert.get_serial_number()) )
https://stackoverflow.com/questions/39286805
复制相似问题