-
Notifications
You must be signed in to change notification settings - Fork 39
/
gencert.sh
executable file
·38 lines (28 loc) · 1.74 KB
/
gencert.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
#!/usr/bin/env bash
unameOutput="$(uname -sr)"
case "${unameOutput}" in
Linux*Microsoft*) machine=WSL;;
Linux*) machine=Linux;;
Darwin*) machine=MacOS;;
*) machine="${unameOutput}"
esac
echo ">> Generating certificate..."
mkdir -p certs
chmod 0755 ./certs
docker pull docker.eventstore.com/eventstore-utils/es-gencert-cli:latest
docker run --rm --volume $PWD/certs:/tmp --user $(id -u):$(id -g) docker.eventstore.com/eventstore-utils/es-gencert-cli create-ca -out /tmp/ca
docker run --rm --volume $PWD/certs:/tmp --user $(id -u):$(id -g) docker.eventstore.com/eventstore-utils/es-gencert-cli create-node -ca-certificate /tmp/ca/ca.crt -ca-key /tmp/ca/ca.key -out /tmp/node -ip-addresses 127.0.0.1 -dns-names localhost
docker run --rm --volume $PWD/certs:/tmp --user $(id -u):$(id -g) docker.eventstore.com/eventstore-utils/es-gencert-cli create-user -username admin -ca-certificate /tmp/ca/ca.crt -ca-key /tmp/ca/ca.key -out /tmp/user-admin
docker run --rm --volume $PWD/certs:/tmp --user $(id -u):$(id -g) docker.eventstore.com/eventstore-utils/es-gencert-cli create-user -username invalid -ca-certificate /tmp/ca/ca.crt -ca-key /tmp/ca/ca.key -out /tmp/user-invalid
chmod -R 0755 ./certs
if [ "${machine}" == "MacOS" ]; then
echo ">> Installing certificate on ${machine}..."
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain certs/ca/ca.crt
elif [ "$machine" == "Linux" ] || [ "$machine" == "WSL" ]; then
echo ">> Copying certificate..."
cp certs/ca/ca.crt /usr/local/share/ca-certificates/eventstore_ca.crt
echo ">> Installing certificate on ${machine}..."
sudo update-ca-certificates
else
echo ">> Unknown platform. Please install the certificate manually."
fi