从X.509证书中提取原始ASN.1部分

我想从X.509证书中提取原始的hexASN.1数据。 我知道,我可以通过使用DER格式和hexdump来做到这一点。

我对“主题”,“发行者”和他们的原始hexASN1数据等特定部分感兴趣。

使用(第一列中的数字)确定感兴趣部分的偏移量:

openssl x509 -in crt.pem -outform der | openssl asn1parse -inform der -i

例如,如果“主题”条目的偏移量为119.转储该子结构的原始数据:

openssl x509 -in crt.pem -outform der | openssl asn1parse -inform der -i -strparse 119 -noout -out subject.raw

现在打印原始hex数据

cat subject.raw | od –address-radix = n –format = x1 | tr -d'\ n'