Skip to content

Instantly share code, notes, and snippets.

@erik-jenkins
Last active May 21, 2023 08:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erik-jenkins/a4dfdd944d2410fae7bdd7765f330508 to your computer and use it in GitHub Desktop.
Save erik-jenkins/a4dfdd944d2410fae7bdd7765f330508 to your computer and use it in GitHub Desktop.
Script to generate .pfx from Let's Encrypt .pem files
if [ "$#" -ne 3 ]; then
echo "Usage: letsencrypt_generate_pfx.sh <domain> <password> <output>"
echo "Example: letsencrypt_generate_pfx.sh fingerguns.co p4ssw0rd /some/dir/certificate.pfx"
exit 1
fi
domain=$1
password=$2
output=$3
openssl pkcs12 \
-export -out $output \
-inkey /etc/letsencrypt/live/$domain/privkey.pem \
-in /etc/letsencrypt/live/$domain/cert.pem \
-certfile /etc/letsencrypt/live/$domain/chain.pem \
-password pass:$password
@erik-jenkins
Copy link
Author

Put this script somewhere and add a certbot post-deploy hook to call this and generate the .pfx file for ASP.NET Core to read. The webserver will need to be restarted on renewal as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment