forked from TheCoopNetwork/GMD-blockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pem.to.pkcs12.keystore.certbot.hook.sh
executable file
·54 lines (41 loc) · 1.67 KB
/
pem.to.pkcs12.keystore.certbot.hook.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
#######################################################################
## This script takes the pem files from a Let's Encrypt / Certbot
## directory and bundles them together for use by the current NRS
## installation, reading the corresponding properties from the
## nxt.properties file.
##
## It is designed to be run from the --deploy-hook Certbot option,
## meaning that it expects the RENEWED_LINEAGE environment variable
## to point to a directory with the PEM encoded files.
#######################################################################
PROPERTIES_PATH="conf/nxt.properties"
if [ -z $RENEWED_LINEAGE ]; then
echo "RENEWED_LINEAGE environment variable not found, running from certbot --deploy-hook ?"
exit
fi
OLD_DIR="$(pwd)"
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
cd $SCRIPTPATH
if [ ! -r $PROPERTIES_PATH ]; then
echo "nxt.properties file not found"
exit
fi
KEYSTORE=$(grep "^nxt.keyStorePath=" $PROPERTIES_PATH | cut -d'=' -f2)
if [ -z $KEYSTORE ]; then
echo "You need to define nxt.keyStorePath on nxt.properties"
exit
fi
KEYSTORE_PASS=$(grep "^nxt.keyStorePassword=" $PROPERTIES_PATH | cut -d'=' -f2)
if [ -z $KEYSTORE_PASS ]; then
echo "You need to define nxt.keyStorePassword on nxt.properties"
exit
fi
KEYSTORE_TYPE=$(grep "^nxt.keyStoreType=" $PROPERTIES_PATH | cut -d'=' -f2)
if [ -z $KEYSTORE_TYPE ] || [ $KEYSTORE_TYPE != "PKCS12" ]; then
echo "You need to define the keystore type as PKCS12. Add \"nxt.keyStoreType=PKCS12\" to your nxt.properties file "
exit
fi
openssl pkcs12 -export -in $RENEWED_LINEAGE/fullchain.pem -inkey $RENEWED_LINEAGE/privkey.pem -out $KEYSTORE -name nrs -passout pass:$KEYSTORE_PASS
chmod a+r $KEYSTORE
cd $OLD_DIR