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

mig*_*ghq 6 openssl x509

我想从 X.509 证书中提取原始十六进制 ASN.1 数据。我知道,我可以通过使用 DER 格式并对其进行十六进制转储来做到这一点。

我对“主题”、“发行人”及其原始十六进制 ASN1 数据等特定部分感兴趣。

mig*_*ghq 8

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

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

现在打印原始十六进制数据:

猫主题.raw | od --address-radix=n --format=x1 | tr -d '\n'