]> WPIA git - gigi.git/blob - keys/generateKeys.sh
Make default name in generateKeys.sh configurable
[gigi.git] / keys / generateKeys.sh
1 #!/bin/bash
2 # this script generates a set of sample keys
3 DOMAIN="cacert.local"
4 KEYSIZE=4096
5 [ -f config ] && . config
6
7
8 rm -Rf *.csr *.crt *.key *.pkcs12 testca
9
10 openssl genrsa -out testca.key ${KEYSIZE}
11 openssl req -new -key testca.key -out testca.csr -subj "/CN=local cacert-gigi testCA" -config selfsign.config
12 openssl x509 -req -days 365 -in testca.csr -signkey testca.key -out testca.crt
13
14 mkdir testca
15 mkdir testca/newcerts
16 echo 01 > testca/serial
17 touch testca/db
18 echo unique_subject = no >testca/db.attr
19
20 genserver(){
21
22 openssl genrsa -out $1.key ${KEYSIZE}
23 openssl req -new -key $1.key -out $1.csr -subj "/CN=$1.${DOMAIN}" -config selfsign.config
24 openssl ca -cert testca.crt -keyfile testca.key -in $1.csr -out $1.crt -days 356 -batch -config selfsign.config
25
26 openssl pkcs12 -inkey $1.key -in $1.crt -name $1 -export -passout pass:changeit -out $1.pkcs12
27
28 keytool -importkeystore -noprompt -srckeystore $1.pkcs12 -destkeystore  ../config/keystore.pkcs12 -srcstoretype pkcs12 -deststoretype pkcs12 -srcstorepass "changeit" -deststorepass "changeit"
29
30 }
31
32 genserver www
33 genserver secure
34 genserver static
35 genserver api
36
37 keytool -list -keystore ../config/keystore.pkcs12 -storetype pkcs12 -storepass "changeit"