Issue#36: .deb deploys default TLS certificate and private key (#39)

* issue#36: Generating TLS key and self-signed cert after installing/upgrading the package

* issue#36: Updated libstdc++.a dependency to v10

* issue#36: Generate self-signed certs after install/upgrade

* issue#36: Updated dependencies

* issue#36: Check for pre-existence of key/cert
pull/52/head
key-networks 4 years ago committed by GitHub
parent 537a567e29
commit ab057c854c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,19 @@
#!/bin/bash
ETC='/opt/key-networks/ztncui/etc' ETC='/opt/key-networks/ztncui/etc'
echo "Copying default password file..." if [ -f ${ETC}/passwd ]; then
cp -pv $ETC/default.passwd $ETC/passwd echo "Password file aready exists"
else
echo "Copying default password file..."
cp -pv ${ETC}/default.passwd ${ETC}/passwd
fi
if [ -f /opt/key-networks/ztncui/etc/tls/privkey.pem ] && [ -f /opt/key-networks/ztncui/etc/tls/fullchain.pem ]; then
echo "TLS key and certificate already exist"
else
echo "Generating new TLS key and self-signed certificate..."
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout /opt/key-networks/ztncui/etc/tls/privkey.pem -out /opt/key-networks/ztncui/etc/tls/fullchain.pem -subj "/C=XX/ST=YY/L=ZZ/O=Security/OU=SelfSigned/CN=example.com"
fi
chown ztncui.ztncui /opt/key-networks/ztncui/etc/tls/*
echo "Enabling and starting ztncui service..." echo "Enabling and starting ztncui service..."
systemctl enable ztncui systemctl enable ztncui
systemctl start ztncui systemctl start ztncui

@ -1,2 +1,11 @@
#!/bin/bash
if [ -f /opt/key-networks/ztncui/etc/tls/privkey.pem ] && [ -f /opt/key-networks/ztncui/etc/tls/fullchain.pem ]; then
echo "TLS key and certificate already exist"
else
echo "Generating new TLS key and self-signed certificate..."
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout /opt/key-networks/ztncui/etc/tls/privkey.pem -out /opt/key-networks/ztncui/etc/tls/fullchain.pem -subj "/C=XX/ST=YY/L=ZZ/O=Security/OU=SelfSigned/CN=example.com"
fi
chown ztncui.ztncui /opt/key-networks/ztncui/etc/tls/*
systemctl daemon-reload systemctl daemon-reload
systemctl try-restart ztncui systemctl try-restart ztncui

@ -1,10 +1,10 @@
--- /tmp/binding.gyp 2018-07-07 14:38:23.884143337 +0800 --- ../src/node_modules/argon2/binding.gyp
+++ ../src/node_modules/argon2/binding.gyp 2018-07-07 14:39:09.684840870 +0800 +++ ../src/node_modules/argon2/binding.gyp
@@ -47,6 +47,7 @@ @@ -47,6 +47,7 @@
], ],
"cflags+": ["-Wno-cast-function-type"], "cflags+": ["-Wno-cast-function-type"],
"include_dirs+": ["<!(node -e \"require('nan')\")"], "include_dirs+": ["<!(node -e \"require('nan')\")"],
+ "libraries": ["/usr/lib/gcc/x86_64-redhat-linux/9/libstdc++.a"], + "libraries": ["/usr/lib/gcc/x86_64-redhat-linux/10/libstdc++.a"],
"dependencies": ["libargon2"], "dependencies": ["libargon2"],
"configurations": { "configurations": {
"Debug": { "Debug": {

@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh
set -e
THISDIR=`pwd` THISDIR=`pwd`
if [ `basename $THISDIR` != 'build' ]; then if [ `basename $THISDIR` != 'build' ]; then
echo "Execute `basename $0` from the build directory" echo "Execute `basename $0` from the build directory"
@ -22,20 +24,21 @@ LICENSE='GPLv3'
BINDINGGYP='node_modules/argon2/binding.gyp' BINDINGGYP='node_modules/argon2/binding.gyp'
if [ ! -f /usr/lib/gcc/x86_64-redhat-linux/9/libstdc++.a ]; then NODE_VER='v8'
if [ ! -f /usr/lib/gcc/x86_64-redhat-linux/10/libstdc++.a ]; then
echo "You must install libstdc++-static" echo "You must install libstdc++-static"
exit 1 exit 1
fi fi
if [ ! -f /usr/bin/rpmbuild ]; then DEPS="rpmbuild rpmsign npm node"
echo "You must install rpm-build"
exit 1
fi
if [ ! -f /usr/bin/rpmsign ]; then for DEP in ${DEPS}; do
echo "You must install rpm-sign" if ! which ${DEP}; then
exit 1 echo "Missing dependency ${DEP}"
fi exit 1
fi
done
rm -fr $STAGING_DIR && mkdir $STAGING_DIR rm -fr $STAGING_DIR && mkdir $STAGING_DIR
rm -fr $PKG_DIR && mkdir $PKG_DIR rm -fr $PKG_DIR && mkdir $PKG_DIR
@ -43,6 +46,15 @@ rm -fr $PKG_DIR && mkdir $PKG_DIR
pushd . pushd .
cd ../src cd ../src
pushd . pushd .
NVER=`node --version`
if [[ ${NVER%%.*} != ${NODE_VER} ]]; then
echo "Missing dependency node ${NODE_VER}"
exit 1
fi
[[ -d ../src/node_modules ]] && rm -fr ../src/node_modules
npm install npm install
patch --forward --dry-run --silent $BINDINGGYP $BUILD_DIR/binding.gyp.patch patch --forward --dry-run --silent $BINDINGGYP $BUILD_DIR/binding.gyp.patch
@ -81,8 +93,6 @@ install -m 644 $BUILD_DIR/ztncui.service $STAGING_DIR/lib/systemd/system
rm -f $BUILD_DIR/ztncui rm -f $BUILD_DIR/ztncui
openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -keyout $STAGING_DIR/opt/key-networks/ztncui/etc/tls/privkey.pem -out $STAGING_DIR/opt/key-networks/ztncui/etc/tls/fullchain.pem -config $BUILD_DIR/openssl.cnf
GENERAL_FPM_FLAGS=" GENERAL_FPM_FLAGS="
--name $NAME --name $NAME
--version $VERSION --version $VERSION
@ -92,6 +102,7 @@ GENERAL_FPM_FLAGS="
--package $PKG_DIR --package $PKG_DIR
--directories /opt/key-networks --directories /opt/key-networks
--depends zerotier-one --depends zerotier-one
--depends openssl
--before-install before-install.sh --before-install before-install.sh
--after-install after-install.sh --after-install after-install.sh
--before-remove before-remove.sh --before-remove before-remove.sh

@ -1,6 +1,6 @@
{ {
"name": "ztncui", "name": "ztncui",
"version": "0.5.8", "version": "0.6.3",
"private": true, "private": true,
"scripts": { "scripts": {
"start": "node ./bin/www", "start": "node ./bin/www",
@ -17,9 +17,9 @@
"express-session": "^1.15.6", "express-session": "^1.15.6",
"express-validator": "^4.3.0", "express-validator": "^4.3.0",
"got": "^7.1.0", "got": "^7.1.0",
"helmet": "^3.12.0", "helmet": "^3.23.0",
"ip-address": "^5.8.9", "ip-address": "^5.8.9",
"jquery": "^3.4.1", "jquery": "^3.5.1",
"morgan": "~1.9.1", "morgan": "~1.9.1",
"node-persist": "^2.1.0", "node-persist": "^2.1.0",
"pug": "^2.0.4", "pug": "^2.0.4",

Loading…
Cancel
Save