Converting SSL Certificate for Nginx 🔐
Nginx native use two files for handling ssl certificate in nginx.conf
.
1
2
ssl_certificate /etc/ssl/cert.pem;
ssl_certificate_key /etc/ssl/private.key;
But most of the vendors sells certificate in .pfx
format with password,
so to convert we first needs to install openssl
and then extract the private key
1
openssl pkcs12 -in certificate.pfx -nocerts -nodes -out private.key
and extract certificate key via
1
openssl pkcs12 -in certificate.pfx -clcerts -nokeys -out cert.pem
Next replace old files with new and restart nginx :D
Of course better is to use nginx certbot with let’s encrypt but this is not always possible.
This post is licensed under CC BY 4.0 by the author.