Created
May 8, 2024 02:38
-
-
Save plambrechtsen/ed366e3ec1c564d579c071d6418f1856 to your computer and use it in GitHub Desktop.
Lets Encrypt Certbot to Cisco ASA CLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
org=org.nz | |
echo "Applying VPN Cert for $1" | |
certbot certonly --config-dir . --preferred-challenges dns --authenticator certbot-dns-standalone:dns-standalone -d $1.$org | |
openssl pkcs12 -export -out $1 -passout pass:password -in live/$1.$org/cert.pem -inkey live/$1.$org/privkey.pem | |
# If you have a newer version of openssl you may need to add -legacy to generate legacy version of the PKCS12 file needed by the ASA. | |
date=`date --date="$(openssl x509 -in live/$1.$org/cert.pem -enddate -noout | cut -d= -f 2)" +%Y%m%d` | |
mv $1 $1-$date.p12 | |
cat > $1.output.txt <<EOF | |
conf term | |
crypto ca import `echo $1-$date` pkcs12 password | |
-----BEGIN PKCS12----- | |
`base64 $1-$date.p12` | |
-----END PKCS12----- | |
quit | |
EOF | |
cat $1.output.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment