1
0
mirror of https://github.com/GNS3/gns3-server synced 2025-01-12 17:10:55 +00:00

Added HOME support and cert dir to create_cert script

This commit is contained in:
Michael 2014-09-02 22:17:06 -06:00
parent 99a8f5f21a
commit bcf0aae531

View File

@ -29,6 +29,11 @@
# Script accepts a single argument, the fqdn for the cert # 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" DOMAIN="$1"
if [ -z "$DOMAIN" ]; then if [ -z "$DOMAIN" ]; then
DOMAIN="gns3server.localdomain.com" DOMAIN="gns3server.localdomain.com"
@ -37,10 +42,16 @@ fi
fail_if_error() { fail_if_error() {
[ $1 != 0 ] && { [ $1 != 0 ] && {
unset PASSPHRASE unset PASSPHRASE
cd $OLD_DIR
exit 10 exit 10
} }
} }
mkdir -p $DST_DIR
fail_if_error $?
cd $DST_DIR
# Generate a passphrase # Generate a passphrase
export PASSPHRASE=$(head -c 500 /dev/urandom | tr -dc a-z0-9A-Z | head -c 128; echo) 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 # 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 $? fail_if_error $?
#openssl rsa -outform der -in $DOMAIN.pem -out $DOMAIN.key -passin env:PASSPHRASE #openssl rsa -outform der -in $DOMAIN.pem -out $DOMAIN.key -passin env:PASSPHRASE
@ -80,3 +91,5 @@ fail_if_error $?
# Generate the cert (good for 10 years) # Generate the cert (good for 10 years)
openssl x509 -req -days 3650 -in $DOMAIN.csr -signkey $DOMAIN.key -out $DOMAIN.crt openssl x509 -req -days 3650 -in $DOMAIN.csr -signkey $DOMAIN.key -out $DOMAIN.crt
fail_if_error $? fail_if_error $?
cd $OLD_DIR