我将PEM格式的PEM证书转换为PKCS7格式,现在我 我跟随here将PKCS7(P7B)证书文件转换回PEM格式。结果PEM文件具有与原始PEM文件类似的内容,但其作为开头具有额外的文本部分。 命令是:
openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer
输出文件(certificate.cer)包含额外部分数据 " ----- BEGIN CERTIFICATION ----- & #34;,如下所示: 前两行:主题和发行人是额外的行。
受试者= / C = VN / ST = HN / L = H / O = MyCompany的/ OU = MyCompany的/ CN = 192.168.5.113
issuer = / C = VN / ST = HN / O = MyCompany / OU = MyCompany证书 Authority / CN = MyCompany中间CA
----- BEGIN CERTIFICATE -----
MIIFwzCCA6ugAwIBAgICEBQwDQYJKoZIhvcNAQELBQAwgYMxCzAJBgNVBAYTAlZO MIGHMQswCQYDVQQGEwJWTjEMMAoGA1UECAwDVFRIMQowCAYDVQQHDAFIMRQwEgYD
VQQKDAtWaWVncmlkIEpTQzEqMCgGA1UECwwhVmllZ3JpZCBKU0MgQ2VydGlmaWNh
dGUgQXV0aG9yaXR5MRwwGgYDVQQDDBNWaWVncmlkIEpTQyBSb290IENBggIQAjAO
BgNVHQ8BAf8EBAMCBaAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwDQYJKoZIhvcNAQEL
BQADggIBAIrU8AyCq2OQzQaAzZeSJMrNCZg8 / pukQcRhdOP + Gg9uIPFU + Sgjodt /
vxczipxZii + qUOk7GGISvVRNFioSojVm8nawI0j5YvXss3 + Zilwo7iqWP71NtO8u
HGsk5GloCKO8cwbk9jQ1YrGXBi2829w1bJZBP1fuspgcdgDcDP0 ++ IXdnYfyZ0eQ
DQ / nwF4EaL2mP6kbZ24pqxem5DBwd3bvP3TMsyboVgKEnFGFZHIQ36y / wIjWp2xn
CSWgi6byohaE6DmSMQ4yzCio38sgQ3fDM3VHnY81AijpFzCeBsIMhQJ9FF8SK + AL
u2IaPU5 + 8XsPyIR6fsuwvuALa7a97gbP3mDoQKwUoIBOmh56cOoJDPj / + pbfg43i
IJIXqk6 / 1ppxWhYS4 / CtHBPas6bbcvQISif5WmEFV + kXmyXitmNCXOS9JSiinlBD
8lvggpzczqa8fOACIipdJ4zdh4a + lUKrAno + SDY + PDGUpmnG5VLdNNBRoYqovTe1
fUcBZxRqVwO1ebZeBpJbQemw1CF / UzQgy1WixddSz / QNTbA821Ym / 8OqoaUhy + PS
idzOIV10iVXP6AOU8chPPnAZmXBgRbibHn8GrjrjXT0ll8YeysBlrmmre2CtY47V
L9u ++ VhNjqBAht / gZnXS8GfGOkN9vNIFTu0MbWn4rrhJrr + tz09t
----- END CERTIFICATE -----
我希望在转换时省略此部分,尝试使用-noout,-text等参数但没有任何作用。我该怎么办?
答案 0 :(得分:1)
谷歌搜索后,我在这里找到了解决方案: https://www.bo.infn.it/alice/introgrd/certmgr/node20.html
"额外部分"是"包属性"。它可以通过以下方式删除:
openssl x509 -in cert.pem -out certout.pem