Added a script to re-generate the host specific server certificate.
authorAkos Frohner <akos.frohner@cern.ch>
Mon, 22 May 2006 13:02:12 +0000 (13:02 +0000)
committerAkos Frohner <akos.frohner@cern.ch>
Mon, 22 May 2006 13:02:12 +0000 (13:02 +0000)
bin/generate-test-certificates.sh
bin/regenerate-host-certificate.sh [new file with mode: 0755]

index fa64a58..24d6fcf 100755 (executable)
@@ -384,6 +384,14 @@ EOF
             done
         fi
     fi
+
+    if [ -r "$CONFIGDIR/../bin/regenerate-host-certificate.sh" ]; then
+        echo "Copying the host-cert re-generation special tool..."
+        if [ ! -d 'bin' ]; then
+            mkdir bin
+        fi
+        cp -u $CONFIGDIR/../bin/regenerate-host-certificate.sh bin/
+    fi
 }
 
 
diff --git a/bin/regenerate-host-certificate.sh b/bin/regenerate-host-certificate.sh
new file mode 100755 (executable)
index 0000000..fde0109
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# The purpose of this script is to re-generate the
+# host specific server certificate in a test deployment.
+#
+# Unlike the other scripts, this is supposed to work
+# in the staged/installed directory only.
+
+set -e
+tempdir="$PWD/$$.tmp"
+trap "rm -rf $tempdir" EXIT
+mkdir -p $tempdir
+
+if [ -n "$1" -a -d "$1/trusted-ca" ]; then
+    export TARGETDIR=$(cd $1; echo $PWD)
+else
+    if [ -d "$(dirname $0)/../trusted-ca" ]; then
+        TARGETDIR=$(cd $(dirname $0)/..; echo $PWD)
+    else
+        echo "Could not find the 'trusted-ca' directory!" >&2
+        exit
+    fi
+fi
+export CA_DIR=$TARGETDIR/trusted-ca
+
+# variables to be used by OpenSSL directly
+export CATYPE=trusted
+export CN=$(hostname --fqdn)
+export BITS=1024
+export PASSWORD='changeit'
+
+filebase="$tempdir/server"
+echo "Re-generating server certificate for '$CN'"
+CMD="openssl req -out $filebase.req -newkey rsa:$BITS -new -keyout $filebase.priv -config $CA_DIR/req_conf.cnf"
+[ -n "$VERBOSE" ] && echo $CMD 
+$CMD
+CMD="openssl ca -in $filebase.req -out $filebase.cert -outdir $tempdir -md md5 -config $CA_DIR/ca_conf.cnf -batch -extensions ca_server -days 1000"
+[ -n "$VERBOSE" ] && echo $CMD 
+$CMD
+
+cp $filebase.cert $TARGETDIR/grid-security/hostcert.pem
+openssl rsa -passin pass:$PASSWORD -in $filebase.priv -out $TARGETDIR/grid-security/hostkey.pem
+