Skip to content

Instantly share code, notes, and snippets.

@mattiasghodsian
Created March 18, 2026 13:59
Show Gist options
  • Select an option

  • Save mattiasghodsian/191591402ad58f904cad76518dce7451 to your computer and use it in GitHub Desktop.

Select an option

Save mattiasghodsian/191591402ad58f904cad76518dce7451 to your computer and use it in GitHub Desktop.
[Linux] Generate custom SSL for local use
#!/bin/bash
# Author: Mattias Ghodsian
# Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
# Donate coffee: https://www.buymeacoffee.com/mattiasghodsian
if [ -z "$1" ]; then
echo "Usage: ./generate.sh yourdomain.lan"
exit 1
fi
DOMAIN=$1
echo "Generating SSL certificate for: $DOMAIN"
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
-keyout "$DOMAIN.key" \
-out "$DOMAIN.crt" \
-subj "/CN=$DOMAIN" \
-addext "subjectAltName=DNS:$DOMAIN,DNS:*.$DOMAIN"
echo "------------------------------------------"
echo "Done! Created files:"
echo "Private Key: $DOMAIN.key"
echo "Certificate: $DOMAIN.crt"
echo "------------------------------------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment