tls-cert-generator
A simple tool with Docker-support to generate TLS certificates
863
No bloat. No complexity. Just one command.
ā
Root CA + Server Certificates ā automatically generated
šÆ Target specific hosts or auto-discover all addresses
ā” Pure shell script ā only requires openssl
š³ macOS ⢠Linux ⢠Docker
Creates and stores a reusable Root CA in certs/root/.
Issues server certificates into certs/servers/<name>/.
Supports:
Individual hostnames, IPs, or FQDNs.
Bulk generation:
all ā all hostnames + IPv4 + IPv6 addresses.all-hostname ā only system hostnames.all-ipv4 ā only system IPv4 addresses.all-ipv6 ā only system IPv6 addresses.Works on Linux and macOS (LibreSSL-compatible).
Automatically uses host networking to detect system IPs when run via Docker on Linux.
Optional flags:
-f ā force overwrite existing keys/certs.-o <dir> ā specify the output certs directory (default ./certs).Automatically maintains a .env file with the current configuration.
The script needs a set of certificate identity fields. You can provide them in four ways (priority order):
| CLI Flag | Env Var | Description | Example |
|---|---|---|---|
-f | N/A | Flag for overwriting existing files | -f |
-o | N/A | Output directory for certs | -o ./my-certs |
--country | COUNTRY | 2-letter country code | --country TR |
--state | STATE | State or province | --state Istanbul |
--locality | LOCALITY | City/locality | --locality Fatih |
--org | ORGANIZATION | Organization name | --org "God Of Kebab Labs" |
--ou | ORGANIZATIONAL_UNIT | Department/unit | --ou "God Of Kebab's Guide to the WWW" |
--cn | ROOT_CN | Root CA Common Name | --cn tls-cert-generator@kebabnet |
Note: Interactive prompts doesn't work when the script is piped into sh
Make sure you have OpenSSL installed (default on Linux/macOS).
Clone the repo and run the script directly:
export COUNTRY="TR"
export STATE="Istanbul"
export LOCALITY="Fatih"
export ORGANIZATION="God Of Kebab Labs"
export ORGANIZATIONAL_UNIT="God Of Kebab's Guide to the WWW"
export ROOT_CN="tls-cert-generator@kebabnet"
# Note: Interactive prompts doesn't work when the script is piped into sh
wget -qO- https://github.com/GodOfKebab/tls-cert-generator/releases/latest/download/tls-cert-generator.sh | sh -s -- \
all 1.2.3.4 example.com
# OR use CLI arguments
wget -qO- https://github.com/GodOfKebab/tls-cert-generator/releases/latest/download/tls-cert-generator.sh | sh -s -- \
-f -o another-certs-folder \
--country "TR" \
--state "Istanbul" \
--locality "Fatih" \
--org "God Of Kebab Labs" \
--ou "God Of Kebab's Guide to the WWW" \
--cn "tls-cert-generator@kebabnet" \
all 1.2.3.4 example.com
# OR save the file before running
# wget https://github.com/GodOfKebab/tls-cert-generator/releases/latest/download/tls-cert-generator.sh -O tls-cert-generator.sh
# sh tls-cert-generator.sh all 1.2.3.4 example.com
Enter COUNTRY (2-letter country code) [XX]:
Enter STATE (State or province) [XX]:
Enter LOCALITY (City/locality) [XX]:
Enter ORGANIZATION (Organization name) [XX]:
Enter ORGANIZATIONAL_UNIT (Department/unit) [XX]:
Enter ROOT_CN (Root CA Common Name) [tls-cert-generator@XX]:
⨠Welcome to tls-cert-generator!
š Current configuration:
FORCE (-f) = 1
CERTS_DIR (-o) = /Users/username/make-tls-certs
COUNTRY (--country) = XX
STATE (--state) = XX
LOCALITY (--locality) = XX
ORGANIZATION (--org) = XX
ORGANIZATIONAL_UNIT (--ou) = XX
ROOT_CN (--cn) = tls-cert-generator@XX
ā³ Generating key for rootCA ...
ā
Success: /Users/username/make-tls-certs/root/rootCA.key
ā³ Generating cert for rootCA ...
ā
Success: /Users/username/make-tls-certs/root/rootCA.crt
ā³ Generating cert/key for HOSTNAME ...
ā
Success: /Users/username/make-tls-certs/servers/HOSTNAME/key.pem
ā
Success: /Users/username/make-tls-certs/servers/HOSTNAME.csr
ā
Success: /Users/username/make-tls-certs/servers/HOSTNAME/cert.pem
ā³ Generating cert/key for HOSTNAME.local ...
ā
Success: /Users/username/make-tls-certs/servers/HOSTNAME.local/key.pem
ā
Success: /Users/username/make-tls-certs/servers/HOSTNAME.local.csr
ā
Success: /Users/username/make-tls-certs/servers/HOSTNAME.local/cert.pem
ā³ Generating cert/key for HOSTNAME.local ...
ā
Success: /Users/username/make-tls-certs/servers/HOSTNAME.local/key.pem
ā
Success: /Users/username/make-tls-certs/servers/HOSTNAME.local.csr
ā
Success: /Users/username/make-tls-certs/servers/HOSTNAME.local/cert.pem
ā³ Generating cert/key for XX.XX.XX.XX ...
ā
Success: /Users/username/make-tls-certs/servers/XX.XX.XX.XX/key.pem
ā
Success: /Users/username/make-tls-certs/servers/XX.XX.XX.XX.csr
ā
Success: /Users/username/make-tls-certs/servers/XX.XX.XX.XX/cert.pem
ā³ Generating cert/key for 127.0.0.1 ...
ā
Success: /Users/username/make-tls-certs/servers/127.0.0.1/key.pem
ā
Success: /Users/username/make-tls-certs/servers/127.0.0.1.csr
ā
Success: /Users/username/make-tls-certs/servers/127.0.0.1/cert.pem
ā³ Generating cert/key for ::1 ...
ā
Success: /Users/username/make-tls-certs/servers/::1/key.pem
ā
Success: /Users/username/make-tls-certs/servers/::1.csr
ā
Success: /Users/username/make-tls-certs/servers/::1/cert.pem
Certificates will be created in ./certs.
A .env file will be written in ./certs/.env with the chosen values.
You can pull and run the prebuilt image without cloning the repo:
Known issues: Dockerized method is not good at detecting the interfaces of your host system (only matters if you run the commands like all, etc.).
docker run --rm \
-v $(pwd)/certs:/app/certs \
-e COUNTRY="TR" \
-e STATE="Istanbul" \
-e LOCALITY="Fatih" \
-e ORGANIZATION="God Of Kebab Labs" \
-e ORGANIZATIONAL_UNIT="God Of Kebab's Guide to the WWW" \
-e ROOT_CN="tls-cert-generator@kebabnet" \
godofkebab/tls-cert-generator \
all 1.2.3.4 example.com
Certificates will be written into ./certs (or wherever you set with -o).
Clone the repo, build the Docker image, and run it:
Known issues: Dockerized method is not good at detecting the interfaces of your host system (only matters if you run the commands like all, etc.).
git clone https://github.com/GodOfKebab/tls-cert-generator.git
cd tls-cert-generator
docker build -t tls-cert-generator .
docker run --rm \
-v $(pwd)/certs:/app/certs \
-e COUNTRY="TR" \
-e STATE="Istanbul" \
-e LOCALITY="Fatih" \
-e ORGANIZATION="God Of Kebab Labs" \
-e ORGANIZATIONAL_UNIT="God Of Kebab's Guide to the WWW" \
-e ROOT_CN="tls-cert-generator@kebabnet" \
tls-cert-generator \
all 1.2.3.4 example.com
Content type
Image
Digest
sha256:dd45d6012ā¦
Size
4 MB
Last updated
9 months ago
docker pull godofkebab/tls-cert-generator