From bcf0aae531d4b09787d1bc9a2ed6f467e32afa4a Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 2 Sep 2014 22:17:06 -0600 Subject: [PATCH] Added HOME support and cert dir to create_cert script --- gns3server/cert_utils/create_cert.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gns3server/cert_utils/create_cert.sh b/gns3server/cert_utils/create_cert.sh index a4e20a81..89a5bc67 100755 --- a/gns3server/cert_utils/create_cert.sh +++ b/gns3server/cert_utils/create_cert.sh @@ -29,6 +29,11 @@ # Script accepts a single argument, the fqdn for the cert +DST_DIR="$HOME/.conf/GNS3Certs/" +OLD_DIR=`pwd` + +#GNS3 Server expects to find certs with the default FQDN below. If you create +#different certs you will need to update server.py DOMAIN="$1" if [ -z "$DOMAIN" ]; then DOMAIN="gns3server.localdomain.com" @@ -37,10 +42,16 @@ fi fail_if_error() { [ $1 != 0 ] && { unset PASSPHRASE + cd $OLD_DIR exit 10 } } +mkdir -p $DST_DIR +fail_if_error $? +cd $DST_DIR + + # Generate a passphrase export PASSPHRASE=$(head -c 500 /dev/urandom | tr -dc a-z0-9A-Z | head -c 128; echo) @@ -56,7 +67,7 @@ emailAddress=gns3cert@gns3.com " # Generate the server private key -openssl genrsa -aes256 -out $DOMAIN.key -passout env:PASSPHRASE 2048 +openssl genrsa -aes256 -out $DST_DIR/$DOMAIN.key -passout env:PASSPHRASE 2048 fail_if_error $? #openssl rsa -outform der -in $DOMAIN.pem -out $DOMAIN.key -passin env:PASSPHRASE @@ -79,4 +90,6 @@ fail_if_error $? # Generate the cert (good for 10 years) openssl x509 -req -days 3650 -in $DOMAIN.csr -signkey $DOMAIN.key -out $DOMAIN.crt -fail_if_error $? \ No newline at end of file +fail_if_error $? + +cd $OLD_DIR \ No newline at end of file