openssl asn1parse 会做到这一点,但您需要进行一些手动解析来确定颁发者序列的开始位置。根据 RFC 5280,它是 TBSCertificate 序列中的第 4 项(如果是 v1 证书,则可能是第 3 项),紧跟在签名算法之后。在以下示例中:
0:d=0 hl=4 l= 621 cons: SEQUENCE
4:d=1 hl=4 l= 470 cons: SEQUENCE
8:d=2 hl=2 l= 3 cons: cont [ 0 ]
10:d=3 hl=2 l= 1 prim: INTEGER :02
13:d=2 hl=2 l= 1 prim: INTEGER :02
16:d=2 hl=2 l= 13 cons: SEQUENCE
18:d=3 hl=2 l= 9 prim: OBJECT :sha1WithRSAEncryption
29:d=3 hl=2 l= 0 prim: NULL
31:d=2 hl=2 l= 64 cons: SEQUENCE
33:d=3 hl=2 l= 11 cons: SET
35:d=4 hl=2 l= 9 cons: SEQUENCE
37:d=5 hl=2 l= 3 prim: OBJECT :countryName
42:d=5 hl=2 l= 2 prim: PRINTABLESTRING :US
46:d=3 hl=2 l= 26 cons: SET
48:d=4 hl=2 l= 24 cons: SEQUENCE
50:d=5 hl=2 l= 3 prim: OBJECT :organizationName
55:d=5 hl=2 l= 17 prim: PRINTABLESTRING :Test Certificates
74:d=3 hl=2 l= 21 cons: SET
76:d=4 hl=2 l= 19 cons: SEQUENCE
78:d=5 hl=2 l= 3 prim: OBJECT :commonName
83:d=5 hl=2 l= 12 prim: PRINTABLESTRING :Trust Anchor
97:d=2 hl=2 l= 30 cons: SEQUENCE
99:d=3 hl=2 l= 13 prim: UTCTIME :010419145720Z
114:d=3 hl=2 l= 13 prim: UTCTIME :110419145720Z
129:d=2 hl=2 l= 59 cons: SEQUENCE
Issuer DN 从偏移量 31 开始,标头长度为 2,值长度为 64,总长度为 66 个字节。当然,这不是那么容易编写脚本...