summaryrefslogtreecommitdiff
path: root/openssl-freefilesync/renew-dummy-cert
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2019-07-16 13:25:19 +0000
committerB Stack <bgstack15@gmail.com>2019-07-16 13:25:19 +0000
commit240c7ecb12cd1ebb9780de70c4d15b0a84854020 (patch)
tree6fb69bb5ec481b1ce68892d0b4c14e7bb75e66c2 /openssl-freefilesync/renew-dummy-cert
parentfreefilesync dpkg add unzip (diff)
parentMerge branch 'freefilesync-rpm' into 'freefilesync-bump' (diff)
downloadstackrpms-240c7ecb12cd1ebb9780de70c4d15b0a84854020.tar.gz
stackrpms-240c7ecb12cd1ebb9780de70c4d15b0a84854020.tar.bz2
stackrpms-240c7ecb12cd1ebb9780de70c4d15b0a84854020.zip
Merge branch 'freefilesync-bump' into 'master'
Freefilesync 10.14 See merge request bgstack15/stackrpms!73
Diffstat (limited to 'openssl-freefilesync/renew-dummy-cert')
-rwxr-xr-xopenssl-freefilesync/renew-dummy-cert39
1 files changed, 39 insertions, 0 deletions
diff --git a/openssl-freefilesync/renew-dummy-cert b/openssl-freefilesync/renew-dummy-cert
new file mode 100755
index 0000000..92e271c
--- /dev/null
+++ b/openssl-freefilesync/renew-dummy-cert
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+if [ $# -eq 0 ]; then
+ echo $"Usage: `basename $0` filename" 1>&2
+ exit 1
+fi
+
+PEM=$1
+REQ=`/bin/mktemp /tmp/openssl.XXXXXX`
+KEY=`/bin/mktemp /tmp/openssl.XXXXXX`
+CRT=`/bin/mktemp /tmp/openssl.XXXXXX`
+NEW=${PEM}_
+
+trap "rm -f $REQ $KEY $CRT $NEW" SIGINT
+
+if [ ! -f $PEM ]; then
+ echo "$PEM: file not found" 1>&2
+ exit 1
+fi
+
+umask 077
+
+OWNER=`ls -l $PEM | awk '{ printf "%s.%s", $3, $4; }'`
+
+openssl rsa -inform pem -in $PEM -out $KEY
+openssl x509 -x509toreq -in $PEM -signkey $KEY -out $REQ
+openssl x509 -req -in $REQ -signkey $KEY -days 365 \
+ -extfile /etc/pki/tls/openssl.cnf -extensions v3_ca -out $CRT
+
+(cat $KEY ; echo "" ; cat $CRT) > $NEW
+
+chown $OWNER $NEW
+
+mv -f $NEW $PEM
+
+rm -f $REQ $KEY $CRT
+
+exit 0
+
bgstack15