Generating Certificates with OpenSSL
1 In OpenSSL, generate a private key using the following command:
openssl genrsa 2048 > private.pem
2 Generate the self-signed certificate using the following command:
openssl req -x509 -days 1000 -new -key private.pem -out public.pem
3 Create the PFX using the following command:
openSSL pkcs12 -export -in public.pem -inkey private.pem -out mycert.pfx
Creating PKCS#12
To create a PKCS#12 file with the self-signed certificate and private key, use the following command:
openssl pkcs12 –export –out mycert.pfx –inkey key.pem –in mycert.pem
from: https://documentation.decisions.com/v9/docs/generating-certificates-with-openssl