Generate x509 certificate in pem, cer and pfx and export public key

Generate x509 cerntifcate

c:\Demo>openssl req -x509 -days 365 -newkey rsa:2048 -keyout my-key.pem -out -my-cert.pem

Generating a RSA private key
………………………+++++
…………..+++++
writing new private key to ‘my-key.pem’
Enter PEM pass phrase:
Verifying – Enter PEM pass phrase:
—–
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter ‘.’, the field will be left blank.
—–
Country Name (2 letter code) [AU]:IN
State or Province Name (full name) [Some-State]:Gujarat
Locality Name (eg, city) []:Gandhinagar
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Your Company Name
Organizational Unit Name (eg, section) []:Development
Common Name (e.g. server FQDN or YOUR name) []:www.yourcompany.com
Email Address []:your@emailaddress.com

Generate .PFX file

c:\Demo>openssl pkcs12 -export -in -my-cert.pem -inkey my-key.pem -out my-xero.pfx
Enter pass phrase for my-key.pem:
Enter Export Password:
Verifying - Enter Export Password:

Generate .cer certificate

c:\Demo>openssl pkcs12 -export -in -my-cert.pem -inkey my-key.pem -out my-xero.cer
Enter pass phrase for my-key.pem:
Enter Export Password:
Verifying - Enter Export Password:

Export public key


c:\Demo>openssl pkcs12 -in my-xero.pfx -clcerts -nokeys -out myxeropublic.cer
Enter Import Password:

Reference: https://www.youtube.com/watch?v=3EBXAtyB6ys

Share