Reputation: 1952
I converted a PEM certificate in PEM format to PKCS7 format, now I am following here to convert back a PKCS7 (P7B) certificate file to PEM format. The result PEM file have content similar with the original PEM file, but its has an extra part of text as the begin. The command is:
openssl pkcs7 -print_certs -in certificate.p7b -out certificate.cer
The output file (certificate.cer) contain an extra part of data before the "-----BEGIN CERTIFICATION-----", like below: The first two lines: subject and issuer are the extra lines.
subject=/C=VN/ST=HN/L=H/O=MyCompany/OU=MyCompany/CN=192.168.5.113
issuer=/C=VN/ST=HN/O=MyCompany/OU=MyCompany Certificate Authority/CN=MyCompany Intermediate 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-----
I want to omit this part when converting, tried with parameters like -noout, -text but nothing works. How can I do it?
Upvotes: 0
Views: 2183
Reputation: 1952
After Googling, I found the solution here: https://www.bo.infn.it/alice/introgrd/certmgr/node20.html
The "extra part" is "bag attributes". It can be removed by:
openssl x509 -in cert.pem -out certout.pem
Upvotes: 1