2019年2月1日 星期五

X509 Certificates in PEM or DER format

How to convert to raw output:

> opalssl x509 -in test.pem -noout -text

in python code,

import OpenSSL.crypto
c = open('test.pem').read()
cert = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_PEM, c)
raw=str(OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_TEXT, cert), 'utf-8')
print(raw)

Binary Data, String, and Integer Conversions in Python

In Python 3, struct  will interpret bytes as packed binary data: This module performs conversions between Python values and C structs rep...