-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_server.sh
executable file
·53 lines (36 loc) · 1.15 KB
/
create_server.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /bin/bash
set -e
die() { echo "$*" >&2 ; exit 1; }
test -e config.sh || die "config.sh missing"
. config.sh
######### create cert request
cat <<__EOF__ > openssl.cnf.tmp
distinguished_name = server_distinguished_name
[server_distinguished_name]
__EOF__
openssl req -config openssl.cnf.tmp \
-newkey rsa:4096 -keyout server.key.pem -nodes \
-subj "$server_subject" \
-out server.certreq.pem.tmp \
######### create cert
# max days 825 for macOS 10.15+ and iOS 13+ [1]
#
# [1] https://wiki.geant.org/display/H2eduroam/EAP+Server+Certificate+considerations
cat <<__EOF__ > openssl.ext.tmp
basicConstraints = CA:FALSE
keyUsage = critical, digitalSignature,keyEncipherment
extendedKeyUsage = serverAuth
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid
subjectAltName = DNS:$server_fqdn
${crl_url:+crlDistributionPoints = URI:$crl_url}
__EOF__
# -CAcreateserial required for OpenSSL < 1.1.1r only
openssl x509 \
-in server.certreq.pem.tmp -req \
-CA eduroamCA.cert.pem -CAkey eduroamCA.key.pem \
-out server.cert.pem \
-extfile openssl.ext.tmp \
-days 825 \
-CAcreateserial
rm *.tmp