How To: Convert a PEM Certificate to a PFX file Using OpenSSL

In order to use a digital certificate on a Windows-based system, you may need to convert the certificate from the PEM format to the PFX format. OpenSSL is a command-line tool that can be used to convert certificate files from one format to another. In this article, we will walk through the steps for converting a PEM certificate file to a PFX file using OpenSSL.


Before we begin, you will need the following:

  • The OpenSSL command-line tool installed on your system. If you don't have it installed, you can download it from the OpenSSL website.
  • The PEM format certificate file that you want to convert.
  • The private key that corresponds to the certificate.

Converting a PEM certificate file to a PFX file

To convert a PEM certificate file to a PFX file using OpenSSL, follow these steps:

  1. Open a command prompt or terminal window.
  2. Navigate to the directory that contains the PEM certificate file and the private key file.
  3. Run the following OpenSSL command:
    > openssl pkcs12 -export -out certificate.pfx -inkey privatekey.pem -in certificate.pem

    This command will create a new PFX file named certificate.pfx in the current directory by combining the private key from privatekey.pem and the certificate from certificate.pem.

    Here is a breakdown of the command:

    • openssl: invokes the OpenSSL command-line tool.
    • pkcs12: specifies that we want to create a PKCS#12 file (which is also known as a PFX file).
    • export: indicates that we want to export a certificate.
    • out certificate.pfx: specifies the name of the output PFX file.
    • inkey privatekey.pem: specifies the path to the private key file in PEM format.
    • in certificate.pem: specifies the path to the certificate file in PEM format.
  4. When you run the command, OpenSSL will prompt you to enter a password for the PFX file. Enter a strong password and press Enter.
  5. OpenSSL will prompt you to verify the password. Re-enter the password and press Enter.
  6. OpenSSL will create the PFX file in the current directory.

That's it! You have successfully converted a PEM certificate file to a PFX file using OpenSSL. The resulting PFX file can now be imported into a Windows-based system for use.

Built with our Notion CMS magic. Reach out to recreate and experience this website excellence!