-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen-cert.sh
executable file
·39 lines (31 loc) · 934 Bytes
/
gen-cert.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# https://blog.pinterjann.is/ed25519-certificates.html
fqdn="$1"
echo -n "Fully Qualified Domain Name: [$fqdn] "
read fqdn_in
if [[ -n "$fqdn_in" ]]; then
fqdn="$fqdn_in"
fi
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 > "$fqdn.key"
cat <<CONF >"$fqdn.cfg"
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
prompt = no
[req_distinguished_name]
C = DE
CN = $fqdn
[v3_req]
keyUsage = keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = $fqdn
CONF
openssl req -new -out "$fqdn.csr" -key "$fqdn.key" -config "$fqdn.cfg"
# Show request for information
openssl req -in "$fqdn.csr" -text -noout
# self-sign because we don't havew a CA private key.
openssl x509 -req -days 700 -in "$fqdn.csr" -signkey "$fqdn.key" -out "$fqdn.crt"
# Show certificate information for information
openssl x509 -in "$fqdn.crt" -text -noout