Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Got a .pfx file and need to install an SSL certificate with this? Here’s how I did it. You’ll need to extract the signed public certificate (public key) and the private key without passphrase.
cd /etc/nginx/
mkdir ssl
cd ssl
mv /path/to/pfx/file.pfx .
chmod 400 file.fpx
First extract the public certificate. You might be asked for a password.
openssl pkcs12 -in ./file.pfx -clcerts -nokeys -out public.crt
And extract the private key:
openssl pkcs12 -in ./file.pfx -nocerts -nodes -out private.rsa
Now you can test the server on an arbitrary port, using openssl:
openssl s_server -www -accept 443 -cert ./public.crt -key ./private.rsa
Make sure no one can read the files other than you:
chmod 400 /etc/nginx/ssl/*
With NginX it is now easy to fire up the server. I used a proxy for this, because from an architecture perspective, this is the easiest:
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/public.crt;
ssl_certificate_key /etc/nginx/ssl/private.rsa;
location / {
proxy_set_header Host $host;
proxy_set_header X-Ssl on;
I pass an additional X-Ssl header to the backend so they know we’re publicly serving through the SSL proxy (e.g. for building absolute URL’s). Once you actually know how to do it, it is easy as pie.
With thanks to Yadab Das and Berk D. Demir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment