nix-bitcoin/secrets/generate_secrets.sh

35 lines
1.2 KiB
Bash
Raw Normal View History

#!/bin/sh
2018-11-22 15:51:16 -08:00
SECRETSFILE=secrets/secrets.nix
if [ -e "$SECRETSFILE" ]; then
echo $SECRETSFILE already exists. No new secrets were generated.
2018-11-22 15:51:16 -08:00
exit 1
fi
2018-12-01 08:36:07 -08:00
echo Write secrets to $SECRETSFILE
{
echo \{
echo " bitcoinrpcpassword = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";"
2019-08-05 01:44:38 -07:00
echo " lnd-wallet-password = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";"
2018-12-01 08:36:07 -08:00
echo " lightning-charge-api-token = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";"
2018-12-03 14:33:21 -08:00
echo " liquidrpcpassword = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";"
2018-12-10 08:34:41 -08:00
echo " spark-wallet-password = \"$(apg -m 20 -x 20 -M Ncl -n 1)\";"
2018-12-01 08:36:07 -08:00
echo \}
} >> $SECRETSFILE
2018-11-22 15:51:16 -08:00
echo Done
2019-04-26 02:09:55 -07:00
echo Generate Self-Signed Cert
2019-08-13 13:57:59 -07:00
openssl genrsa -out secrets/nginx.key 2048
openssl req -new -key secrets/nginx.key -out secrets/nginx.csr -subj "/C=KN"
openssl x509 -req -days 1825 -in secrets/nginx.csr -signkey secrets/nginx.key -out secrets/nginx.cert
2019-08-13 14:22:41 -07:00
rm secrets/nginx.csr
2019-04-26 02:09:55 -07:00
echo Done
2019-08-05 01:44:38 -07:00
echo Generate LND compatible TLS Cert
openssl ecparam -genkey -name prime256v1 -out secrets/lnd.key
openssl req -config secrets/openssl.cnf -new -sha256 -key secrets/lnd.key -out secrets/lnd.csr -subj '/CN=localhost/O=lnd'
openssl req -config secrets/openssl.cnf -x509 -sha256 -days 1825 -key secrets/lnd.key -in secrets/lnd.csr -out secrets/lnd.cert
rm secrets/lnd.csr
echo Done