-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgencert
More file actions
executable file
·35 lines (28 loc) · 1.06 KB
/
gencert
File metadata and controls
executable file
·35 lines (28 loc) · 1.06 KB
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
#!/bin/bash
source ./bits/bootstrap/logging
#-----------
# Configurations
#-----------
# https://github.com/sameersbn/docker-gitlab#ssl
DIR=${DIR-/tmp/cert}
OWNER=${OWNER-$USER}
URL=${URL-localhost}
NAME=${NAME-$URL}
GENCERT_OUTPUT=/tmp/gencert_${NAME}.log
OWNER=$OWNER ./bits/bootstrap/mkdir $DIR
if [[ ! -e "$DIR/${NAME}.key" ]]; then
notify " -- generating SSL keys"
SCRIPT_OUTPUT=$(cd $DIR && openssl genrsa -out ${NAME}.key 4096 > $GENCERT_OUTPUT 2>&1)
ERROR="Unable to generate $NAME keys due to ..." ./bits/bootstrap/failonerrors $? $GENCERT_OUTPUT
[ $? -ne 0 ] && exit 1
else
debug " -- Re-using $DIR/${NAME}.key"
fi
if [[ ! -e "$DIR/${NAME}.crt" ]]; then
notify " -- Generating and signing certificate"
SCRIPT_OUTPUT=$(cd $DIR && openssl req -new -key $NAME.key -days 365 -nodes -x509 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=$URL" -out $NAME.crt > $GENCERT_OUTPUT 2>&1)
ERROR="Unable to generate ${NAME}.crt due to ..." ./bits/bootstrap/failonerrors $? $GENCERT_OUTPUT
[ $? -ne 0 ] && exit 1
else
debug " -- Re-using $DIR/${NAME}.crt"
fi