Annotation of embedaddon/curl/tests/certs/scripts/genroot.sh, revision 1.1
1.1 ! misho 1: #!/bin/bash
! 2:
! 3: # (c) CopyRight 2000 - 2020, EdelWeb for EdelKey and OpenEvidence
! 4: # Author: Peter Sylvester
! 5:
! 6: # "libre" for integration with curl
! 7:
! 8: OPENSSL=openssl
! 9: if [ -f /usr/local/ssl/bin/openssl ] ; then
! 10: OPENSSL=/usr/local/ssl/bin/openssl
! 11: fi
! 12:
! 13: USAGE="echo Usage is genroot.sh \<name\>"
! 14:
! 15: HOME=`pwd`
! 16: cd $HOME
! 17:
! 18: KEYSIZE=2048
! 19: DURATION=6000
! 20: # The -sha256 option was introduced in OpenSSL 1.0.1
! 21: DIGESTALGO=-sha256
! 22:
! 23: PREFIX=$1
! 24: if [ ".$PREFIX" = . ] ; then
! 25: echo No configuration prefix
! 26: NOTOK=1
! 27: else
! 28: if [ ! -f $PREFIX-ca.prm ] ; then
! 29: echo No configuration file $PREFIX-ca.prm
! 30: NOTOK=1
! 31: fi
! 32: fi
! 33:
! 34: if [ ".$NOTOK" != . ] ; then
! 35: echo "Sorry, I can't do that for you."
! 36: $USAGE
! 37: exit
! 38: fi
! 39:
! 40: GETSERIAL="\$t = time ;\$d = \$t . substr(\$t+$$ ,-4,4)-1;print \$d"
! 41: SERIAL=`/usr/bin/env perl -e "$GETSERIAL"`
! 42:
! 43: echo SERIAL=$SERIAL PREFIX=$PREFIX DURATION=$DURATION KEYSIZE=$KEYSIZE
! 44:
! 45: echo "openssl genrsa -out $PREFIX-ca.key $KEYSIZE -passout XXX"
! 46: openssl genrsa -out $PREFIX-ca.key $KEYSIZE -passout pass:secret
! 47:
! 48: echo "openssl req -config $PREFIX-ca.prm -new -key $PREFIX-ca.key -out $PREFIX-ca.csr"
! 49: $OPENSSL req -config $PREFIX-ca.prm -new -key $PREFIX-ca.key -out $PREFIX-ca.csr -passin pass:secret
! 50:
! 51: echo "openssl x509 -set_serial $SERIAL -extfile $PREFIX-ca.prm -days $DURATION -req -signkey $PREFIX-ca.key -in $PREFIX-ca.csr -out $PREFIX-$SERIAL.ca-cacert $DIGESTALGO "
! 52:
! 53: $OPENSSL x509 -set_serial $SERIAL -extfile $PREFIX-ca.prm -days $DURATION -req -signkey $PREFIX-ca.key -in $PREFIX-ca.csr -out $PREFIX-$SERIAL-ca.cacert $DIGESTALGO
! 54:
! 55: echo "openssl x509 -text -in $PREFIX-$SERIAL-ca.cacert -nameopt multiline > $PREFIX-ca.cacert "
! 56: $OPENSSL x509 -text -in $PREFIX-$SERIAL-ca.cacert -nameopt multiline > $PREFIX-ca.cacert
! 57:
! 58: echo "openssl x509 -in $PREFIX-ca.cacert -outform der -out $PREFIX-ca.der "
! 59: $OPENSSL x509 -in $PREFIX-ca.cacert -outform der -out $PREFIX-ca.der
! 60:
! 61: echo "openssl x509 -in $PREFIX-ca.cacert -text -nameopt multiline > $PREFIX-ca.crt "
! 62:
! 63: $OPENSSL x509 -in $PREFIX-ca.cacert -text -nameopt multiline > $PREFIX-ca.crt
! 64:
! 65: echo "openssl x509 -noout -text -in $PREFIX-ca.cacert -nameopt multiline"
! 66: $OPENSSL x509 -noout -text -in $PREFIX-ca.cacert -nameopt multiline
! 67:
! 68: #$OPENSSL rsa -in ../keys/$PREFIX-ca.key -text -noout -pubout
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>