# /usr/bin/env sh
#
# Note: This README is executable. If you wish to generate your own certificates
# you can just run this readme in your shell of choice as long as a compatible
# version of openssl is installed.
#
# Both pkcs12 certificates have a password of "password"
#

CWD=`pwd`
SCRIPTDIR=`dirname "$0"`
cd $SCRIPTDIR

# These two certs do not work on my GS1900-8 or GS1900-24E.
#
# They were generated as follows:
#
# prime256v1 key:

  echo "Generating a test prime256v1 key..."
	mkdir -p prime256v1
  
  openssl ecparam -out ./prime256v1/prime256v1.key -name prime256v1 -genkey

  openssl req -new -key ./prime256v1/prime256v1.key -x509 -nodes -days 3650 -out ./prime256v1/prime256v1.pem \
    -subj "/C=AU/ST=Some-State/O=Internet Widgets Pty Ltd/CN=test-prime256v1.example.com"

  openssl pkcs12 -export -out ./prime256v1/prime256v1.pfx -inkey ./prime256v1/prime256v1.key -in ./prime256v1/prime256v1.pem -password "pass:password"

# secp384r1 key:

  echo "Generating a test secp384r1 key..."
	mkdir -p secp384r1
  openssl ecparam -out ./secp384r1/secp384r1.key -name secp384r1 -genkey

  openssl req -new -key ./secp384r1/secp384r1.key -x509 -nodes -days 3650 -out ./secp384r1/secp384r1.pem \
    -subj "/C=AU/ST=Some-State/O=Internet Widgets Pty Ltd/CN=test-secp384r1.example.com"

  openssl pkcs12 -export -out ./secp384r1/secp384r1.pfx -inkey ./secp384r1/secp384r1.key -in ./secp384r1/secp384r1.pem -password "pass:password"

#
# These certificates are generated with the same parameters that my CA wants to use
# but they do not work on either of my switches.

cd $PWD