summaryrefslogtreecommitdiff
path: root/renew-dummy-cert
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2024-08-01 14:09:41 +0000
committerCoprDistGit <infra@openeuler.org>2024-08-01 14:09:41 +0000
commitd8253271bee23ac54145c0ba1d15f48e6620bb5e (patch)
tree470a23e7c4bb3541b4ff08932ce1fbd46fe59c9c /renew-dummy-cert
parent17146a82118c2690c851cbb31077186594ba86d6 (diff)
automatic import of compat-openssl11openeuler24.03_LTSopeneuler23.09
Diffstat (limited to 'renew-dummy-cert')
-rwxr-xr-xrenew-dummy-cert39
1 files changed, 39 insertions, 0 deletions
diff --git a/renew-dummy-cert b/renew-dummy-cert
new file mode 100755
index 0000000..92e271c
--- /dev/null
+++ b/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
+