@@ -15,6 +15,19 @@ if [ "$1" = "" ]; then
15
15
fi
16
16
export host=$1
17
17
export mode=$2
18
+ export wildcard=
19
+ export fileprefix=
20
+ if [ " $mode " = " wildcard" ]; then
21
+ if [ " $host " = " localhost" ]; then
22
+ wildcard=
23
+ for i in ` seq 1 32` ; do {
24
+ wildcard=${wildcard} ,DNS:$i .localhost
25
+ } done ;
26
+ else
27
+ wildcard=,DNS:* .${host} ;
28
+ fi
29
+ fileprefix=wildcard.
30
+ fi
18
31
which openssl
19
32
if [ " $? " = " 1" ]; then
20
33
echo Please install openssl command
@@ -39,11 +52,11 @@ if [ ! -e /* @echo demoCA */.crt ]; then
39
52
echo cd /* @echo keys * /
40
53
echo certutil -d sql:$HOME /.pki/nssdb -A -n ' /* @echo CN */' -i .//* @echo demoCA * ///* @echo demoCA * /.crt -t TCP,TCP,TCP
41
54
fi
42
- if [ ! -e ${host} .key ]; then
43
- openssl genrsa 2048 > ${host} .key
55
+ if [ ! -e ${fileprefix}${ host} .key ]; then
56
+ openssl genrsa 2048 > ${fileprefix}${ host} .key
44
57
fi
45
- if [ ! -e ${host} .csr ]; then
46
- cat > ${host} _csr.txt << -EOF
58
+ if [ ! -e ${fileprefix}${ host} .csr ]; then
59
+ cat > ${fileprefix}${ host} _csr.txt << -EOF
47
60
[req]
48
61
default_bits = 2048
49
62
prompt = no
@@ -59,22 +72,22 @@ OU=/* @echo OU */
59
72
CN=${host}
60
73
61
74
[SAN]
62
- subjectAltName=DNS:${host}
75
+ subjectAltName=DNS:${host}${wildcard}
63
76
EOF
64
- openssl req -config ${host} _csr.txt -new -sha256 -key ${host} .key -out ${host} .csr
65
- openssl req -text -noout -in ${host} .csr
77
+ openssl req -config ${fileprefix}${ host} _csr.txt -new -sha256 -key ${fileprefix}${ host} .key -out ${fileprefix} ${host} .csr
78
+ openssl req -text -noout -in ${fileprefix}${ host} .csr
66
79
fi
67
80
cd ..
68
- if [ ! -e demoCA/${host} .crt ]; then
69
- openssl x509 -req -CA /* @echo demoCA * ///* @echo demoCA * /.crt -CAkey /* @echo demoCA * ///* @echo demoCA * /.key -CAcreateserial -out /* @echo demoCA * //${host} .crt -in /* @echo demoCA * //${host} .csr -sha256 -days 3650 \
70
- -extfile /* @echo demoCA * //${host} _csr.txt -extensions SAN
81
+ if [ ! -e demoCA/${fileprefix}${ host} .crt ]; then
82
+ openssl x509 -req -CA /* @echo demoCA * ///* @echo demoCA * /.crt -CAkey /* @echo demoCA * ///* @echo demoCA * /.key -CAcreateserial -out /* @echo demoCA * //${fileprefix}${ host} .crt -in /* @echo demoCA * //${fileprefix} ${host} .csr -sha256 -days 3650 \
83
+ -extfile /* @echo demoCA * //${fileprefix}${ host} _csr.txt -extensions SAN
71
84
fi
72
85
if [ " $mode " = " client" ]; then
73
- if [ ! -e /* @echo demoCA * //${host} .pfx ]; then
86
+ if [ ! -e /* @echo demoCA * //${fileprefix}${ host} .pfx ]; then
74
87
echo Note: Some browsers may not accept client certificates with empty passwords
75
- openssl pkcs12 -export -inkey /* @echo demoCA * //${host} .key -in /* @echo demoCA * //${host} .crt -out /* @echo demoCA * //${host} .pfx
88
+ openssl pkcs12 -export -inkey /* @echo demoCA * //${fileprefix}${ host} .key -in /* @echo demoCA * //${fileprefix}${ host} .crt -out /* @echo demoCA * //${fileprefix} ${host} .pfx
76
89
echo how to import pfx on Linux:
77
90
echo cd /* @echo keys * /
78
- echo pk12util -d sql:$HOME /.pki/nssdb -i .//* @echo demoCA * //${host} .pfx
91
+ echo pk12util -d sql:$HOME /.pki/nssdb -i .//* @echo demoCA * //${fileprefix}${ host} .pfx
79
92
fi
80
93
fi
0 commit comments