The commands below demonstrate examples of how to create a .pfx/.p12 file in the command line using OpenSSL.
PEM (.pem, .crt, .cer) to PFX
Breaking down the command:
- openssl – the command for executing OpenSSL
- pkcs12 – the file utility for PKCS#12 files in OpenSSL
- –export –out certificate.pfx – export and save the PFX file as certificate.pfx
- –inkey privateKey.key – use the private key file privateKey.key as the private key to combine with the certificate.
- –in certificate.crt – use certificate.crt as the certificate the private key will be combined with.
- –certfile more.crt – This is optional, this is if you have any additional certificates you would like to include in the PFX file.