Skip to content

Instantly share code, notes, and snippets.

@kopiro
Last active December 13, 2017 16:03
Show Gist options
  • Save kopiro/c89f709c9ba8d90fe7672f000db53565 to your computer and use it in GitHub Desktop.
Save kopiro/c89f709c9ba8d90fe7672f000db53565 to your computer and use it in GitHub Desktop.
SSL Renewal with LE using same CSR
#!/bin/bash
CONTAINER="/var/www/html"
DOMAIN="kopiro.it"
PUBLIC_DIR="$CONTAINER/public"
BACKUP_DIR="$CONTAINER/conf/backup/$(date +%s)"
mkdir -p "$BACKUP_DIR"
cp -v $CONTAINER/conf/*.pem "$BACKUP_DIR/"
rm "$CONTAINER/conf/cert.pem"
rm "$CONTAINER/conf/chain.pem"
rm "$CONTAINER/conf/fullchain.pem"
certbot-auto certonly \
--non-interactive \
--agree-tos \
--email "[email protected]" \
-a webroot \
-w "$PUBLIC_DIR" \
--rsa-key-size 4096 \
--csr "$CONTAINER/conf/csr.pem" \
--domain "$DOMAIN" \
--cert-path "$CONTAINER/conf/cert.pem" \
--chain-path "$CONTAINER/conf/chain.pem" \
--fullchain-path "$CONTAINER/conf/fullchain.pem" &&
nginx -t &&
nginx -s reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment