Skip to content
Menu
vernon.wenberg.net
vernon.wenberg.net
November 9, 2022November 9, 2022

Create a .pfx/.p12 Certificate File Using OpenSSL

Source: https://www.ssl.com/how-to/create-a-pfx-p12-certificate-file-using-openssl/

The PKCS#12 or PFX format is a binary format for storing the server certificate, any intermediate
certificates, and the private key into a single encryptable file. PFX files are usually found with the
extensions .pfx and .p12. PFX files are typically used on Windows and macOS machines to import and
export certificates and private keys.

Requirements

  • The original private key used for the certificate
  • A PEM (.pem, .crt, .cer) or PKCS#7/P7B (.p7b, .p7c) File
  • OpenSSL (included with Linux/Unix and macOS, and easily installed on Windows with Cygwin or Windows Subsystem for Linux)

The commands below demonstrate examples of how to create a .pfx/.p12 file in the command line
using OpenSSL:

openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile more.crt

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.
  • Older versions of Windows Server will not recognize the password you set for your .pfx file even if you do not set a password. To fix this, include -legacy option in your command.

Note: After entering the command, you will be prompted to enter and verify an export
password to protect the PFX file. Remember this password! You will need it when you wish
to export the certificates and key.

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to print (Opens in new window) Print
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn

Like this:

Like Loading...

Related

Disclaimer

These posts are notes for me. These are not guides and you should not use these instructions as step-by-step instructions without knowing what they do.

Recent Posts

  • HPE Aruba-CX Notes
  • Docker Reference
  • Useful Commands for Windows Subsystem for Linux
  • FortiManager Local-In Policy
  • Mount Google Drive in Linux using rclone

Mastodon

  1. Loading Mastodon feed...

©2025 vernon.wenberg.net | Powered by WordPress and Superb Themes!
%d