-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup-certs.sh
24 lines (23 loc) · 930 Bytes
/
setup-certs.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
#!/bin/bash
red=$'\e[1;31m'
grn=$'\e[1;32m'
end=$'\e[0m'
mkdir -p pki
CN=localhost
P12PASS=changeit
TRUSTPASS=changeit
generate_files() {
echo "Generating Key pair.."
openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout pki/private.key -out pki/cert.crt -subj "/CN=$CN" &> /dev/null
echo "Generating PKCS12.."
openssl pkcs12 -export -inkey pki/private.key -in pki/cert.crt -out pki/certificate.p12 -name "$CN" -password pass:$P12PASS
cat pki/cert.crt >> pki/ca.pem
echo "Verifying created configuration .."
if [[ -f pki/ca.pem && -f pki/certificate.p12 && -f pki/cert.crt && -f pki/private.key ]]; then
echo "${grn}Verification successfull.${end}"
echo "${grn}You can now run --- docker-compose up ---${end}"
else
echo "${red}Verification unsuccessfull, please make sure that You have permission to create file in this location and OpenSSL package is avaliable${end}"
fi
}
generate_files