Skip to content

Instantly share code, notes, and snippets.

@hctilg
Created July 17, 2026 06:16
Show Gist options
  • Select an option

  • Save hctilg/1f4b159b26b56b44125d4b5bf7d4aa9e to your computer and use it in GitHub Desktop.

Select an option

Save hctilg/1f4b159b26b56b44125d4b5bf7d4aa9e to your computer and use it in GitHub Desktop.
Get Free SSL For Your Domains With CloudFlare
#!/usr/bin/env bash
CF_Account_ID=""
CF_Token=""
EMAIL=""
export CF_Account_ID
export CF_Token
export PATH="$HOME/.acme.sh:$PATH"
if [ ! -f ~/.acme.sh/acme.sh ]; then
echo "[+] Installing acme.sh..."
curl https://get.acme.sh | sh
source ~/.bashrc || source ~/.profile || true
fi
if ! command -v acme.sh &> /dev/null; then
echo "[-] acme.sh not found in PATH."
exit 1
fi
echo "What do you want to do?"
select OPTION in "Issue new SSL certificate" "Renew existing certificates" "Exit"; do
case $REPLY in
1)
read -p "Enter your domain name (e.g., example.com): " DOMAIN
echo "[+] Registering account with Let's Encrypt..."
acme.sh --register-account -m "$EMAIL" --server letsencrypt
echo "[+] Setting Let's Encrypt as default CA..."
acme.sh --set-default-ca --server letsencrypt
echo "[+] Issuing SSL certificate for $DOMAIN..."
acme.sh --issue --dns dns_cf -d "$DOMAIN" --force
echo "[+] Installing certificate to current directory..."
acme.sh --install-cert -d "$DOMAIN" \
--key-file "./privkey.pem" \
--fullchain-file "./fullchain.pem"
echo "[✓] SSL certificate for $DOMAIN has been created."
echo "→ Saved files: privkey.pem, fullchain.pem"
break
;;
2)
echo "[+] Renewing all certificates..."
acme.sh --renew-all --force
echo "[✓] All certificates have been renewed."
break
;;
3)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid option. Please choose 1, 2, or 3."
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment