Q&A: How to convert a crt certificate to pfx|p12|pkcs12 format

Question:

How can a crt certificate be converted to the windows pfx|p12|pkcs12 format?

Answer:

You can just use openssl to do the job for you.
Choose the extension that fits your need, the file formates are all the same.

1. without the private key

root@ucs:~# openssl pkcs12 -export -out ucsCA.pfx|p12|pkcs12 -in /etc/univention/ssl/ucsCA/CAcert.pem \
  -nokeys

2. including the private key

root@ucs:~# openssl pkcs12 -export -out ucsCA.pfx|p12|pkcs12 -in /etc/univention/ssl/ucsCA/CAcert.pem \
  -inkey /etc/univention/ssl/ucsCA/private/CAkey.pem -passin "pass:$(cat /etc/univention/ssl/password)"

Check the generated certificate

Finally you should check the generated certificate before using it.

 root@ucs:~# openssl pkcs12 -info -in ucsCA.pfx|p12|pkcs12
Mastodon