Skip to content

Instantly share code, notes, and snippets.

@alainwolf
Last active January 9, 2017 16:13
Show Gist options
  • Save alainwolf/001d3a17d09bbb5baacf76b62265af9d to your computer and use it in GitHub Desktop.
Save alainwolf/001d3a17d09bbb5baacf76b62265af9d to your computer and use it in GitHub Desktop.
SSL Certficate for Servers on Dynamic IP Addresses
#!/bin/sh
#
# Cronjob for Let's Encrypt certifcate for hosts on dynamic IP.
#
# Uses letsencrypt/acme client implemented as a shell-script
# – just add water https://dehydrated.de
#
# Please don't use HSTS or HPKP headers on dynamic IPs as they
# will affect other customers using your IP in the future.
#
# Hostname for dynamic IP
dyndomain=$(dig +short -x $(curl --ipv4 --silent icanhazip.com))
# Remove trailing dot
dyndomain=${dyndomain%.}
# Get cert
/usr/local/lib/dehydrated/dehydrated --cron --domain ${dyndomain}
# Update symlink (could also be implemeted in hook script)
ln --symbolic --force /etc/dehydrated/certs/${dyndomain} /etc/dehydrated/certs/dyndomain
@alainwolf
Copy link
Author

Please don't use HSTS or HPKP headers on dynamic IPs as they will affect other customers using your IP in the future.

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