X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=testkit%2Flibrary%2Fgen_cert_from_ca.sh;fp=testkit%2Flibrary%2Fgen_cert_from_ca.sh;h=d068ea0e9d5d683422507574174b03577f215502;hb=d46483c93ecc9a4ef7d80656d23bd0891ddf5ac6;hp=0000000000000000000000000000000000000000;hpb=4e15bc3b03c452086296b0b2e8dab709f34b5957;p=feisty_meow.git diff --git a/testkit/library/gen_cert_from_ca.sh b/testkit/library/gen_cert_from_ca.sh new file mode 100644 index 00000000..d068ea0e --- /dev/null +++ b/testkit/library/gen_cert_from_ca.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +#hmmm: NOT ported to testkit yet. + +# creates a new certificate based on the grid's signing cert. +# +# Author: Chris Koeritz + +############## + +#### + +export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )" # obtain the script's working directory. + +# pull in the xsede test base support. +source "$WORKDIR/../prepare_tools.sh" "$WORKDIR/../prepare_tools.sh" + +# if that didn't work, complain. +if [ -z "$TESTKIT_SENTINEL" ]; then echo Please run prepare_tools.sh before testing.; exit 3; fi + +# load the bash libraries we need. +source "$TESTKIT_ROOT/library/helper_methods.sh" +#source "$TESTKIT_ROOT/library/runner_functions.sh" +source "$TESTKIT_ROOT/library/security_management.sh" + +#### + +if [ $# -lt 7 ]; then + echo "this script needs 7 parameters:" + echo "1: signing cert PFX file to base new cert on." + echo "2: the password for the signing cert PFX." + echo "3: the alias of the key to use within the signing PFX." + echo "4: output file to create with new certificate in PFX format." + echo "5: password for new certificate PFX file." + echo "6: alias for the certificate within the PFX file." + echo "7: Common Name (CN) of the identity signified by the new certificate." + echo + echo "This is an example run using a signing cert for a container:" + echo + echo 'bash $TESTKIT_ROOT/library/gen_cert_from_ca.sh signing-cert.pfx signer signing-cert $HOME/new_cert.pfx myPassword certalias "Fred Powers"' + exit 1 +fi + +signing_cert="$1"; shift +signing_passwd="$1"; shift +signing_alias="$1"; shift +output_file="$1"; shift +output_passwd="$1"; shift +output_alias="$1"; shift +output_cn="$1"; shift + +create_pfx_using_CA "$signing_cert" "$signing_passwd" "$signing_alias" "$output_file" "$output_passwd" "$output_alias" "$output_cn" +check_if_failed "generating '$output_file' from '$signing_cert'" + +echo "New certificate was generated into: $output_file" + +exit 0 +