0

I need to convert PKCS7 certificate to PKCS12. I got function which return PKCS7 certificate format and in order to put this certificate to IBM certificate manager I need to convert this certificate to PKCS12 PEM format. Do you have any idea how to do that. I'm using JAVA.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
JakubBrehuv
  • 3
  • 1
  • 5
  • It is impossible. PKCS#12 format requires private key, but PKCS#7 doesn't offer it. – Crypt32 Jun 06 '18 at 04:24
  • What if connect my generated private key to PKCS#7 and create PKCS#12 after that ? – JakubBrehuv Jun 06 '18 at 06:16
  • PKCS#7 doesn't support private keys, you can't attach them there. – Crypt32 Jun 06 '18 at 07:21
  • @Crypt32: not strictly true; PKCS12 is _usually_ used for privatekey+certchain, but the format is capable of storing cert(s) alone and Java 8+ supports using it that way (aka as a truststore). But most other software doesn't, and I don't know about 'IBM certificate manager'. – dave_thompson_085 Jun 06 '18 at 08:54
  • OP: Java `CertificateFactory.getInstance("X.509").generateCertificates(InputStream)` -- note plural Certificate*s* -- can read PKCS7-certs-only (often called p7b or p7c). But reading the privatekey may be harder, sometimes much harder. And are you sure you want PEM? Almost nobody uses PEM for PKCS12. (For certs, CSR, many types of keys including PKCS8, sometimes CMS/PKCS7 including p7b/c, but not PKCS12.) – dave_thompson_085 Jun 06 '18 at 08:55
  • `but the format is capable<...>` this case is not related to the subject. – Crypt32 Jun 06 '18 at 09:34

1 Answers1

0

Try using the following command to convert PKCS7 to PEM: openssl pkcs7 -print_certs -in certificate.p7b -out certificate.pem

link

Or you can also use the SSL Shopper converter: https://www.sslshopper.com/ssl-converter.html

idohu
  • 133
  • 3
  • 7