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