Skip to content

Instantly share code, notes, and snippets.

@Razuuu
Last active August 28, 2023 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Razuuu/86debde46122acc1750dae4b787db687 to your computer and use it in GitHub Desktop.
Save Razuuu/86debde46122acc1750dae4b787db687 to your computer and use it in GitHub Desktop.
Create wildcard letsencrypt certificate with rfc2136 - Custom nameservers
#!/bin/bash
# ------------------------------------------------------
# Functions - Common
# ------------------------------------------------------
DOMAIN=$1
SUBDOMAIN=$2
# See https://certbot-dns-rfc2136.readthedocs.io/en/stable/ for certbot.ini
COMMAND="certbot certonly --dns-rfc2136 --dns-rfc2136-credentials /root/.secrets/certbot.ini"
# Request a ssl certificate for $DOMAIN
function request_ssl_certificate() {
if [ -z $SUBDOMAIN ]; then
$COMMAND -d *.${DOMAIN} -d $DOMAIN
else
$COMMAND -d *.${DOMAIN} -d $DOMAIN -d *.${SUBDOMAIN}.${DOMAIN}
fi
}
# Checks if $DOMAIN is empty
function check_var_empty() {
if [ -z $DOMAIN ]; then
echo "bash `basename $0` <Domain> <Subdomain (optional)>"
exit 0
fi
}
# ------------------------------------------------------
# Script - Start
# ------------------------------------------------------
check_var_empty
request_ssl_certificate
# ------------------------------------------------------
# Script - End
# ------------------------------------------------------
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment