Create a X509 certificate and .pfx (p12) file using OpenSSL

Please follow the below code to generate the X509 certificate using openSSL

The first step is to generate the certificate with the private key. For this open your Open SSL command prompt and type in the below command

openssl req -newkey rsa:2048 -nodes -keyout private.key -x509 -days 365 -out certificate.cer

You will be prompted to enter few details related to the certificate as shown in the screenshot below. You can enter the details as per your requirement.

Once you execute the command, you will find the certificate and the private key file created in the folder.

The next step is to combine the key and certificate and generate the .pfx file. To do this, execute the below command

openssl pkcs12 -inkey private.key -in certificate.cer -export -out certificate.pfx

You will be asked to enter and verify the password. Make sure you remember this password.

And your .pfx file will now be generated.

You are all set to now use the self signed SSL certificate.

Hope this helped. If you liked this post, you can buy me a coffee. Link on the right pane.

You will also like the below posts.

Debajit Dutta
Business Solutions MVP

1 thought on “Create a X509 certificate and .pfx (p12) file using OpenSSL”

  1. Pingback: Connect to SharePoint search API from POSTMAN - Debajit's Power Apps & Dynamics 365 Blog

Comments are closed.