bringing in testkit tools
[feisty_meow.git] / testkit / library / gen_cert_from_ca.sh
1 #!/bin/bash
2
3 #hmmm: NOT ported to testkit yet.
4
5 # creates a new certificate based on the grid's signing cert.
6 #
7 # Author: Chris Koeritz
8
9 ##############
10
11 ####
12
13 export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )"  # obtain the script's working directory.
14
15 # pull in the xsede test base support.
16 source "$WORKDIR/../prepare_tools.sh" "$WORKDIR/../prepare_tools.sh"
17
18 # if that didn't work, complain.
19 if [ -z "$TESTKIT_SENTINEL" ]; then echo Please run prepare_tools.sh before testing.; exit 3; fi
20
21 # load the bash libraries we need.
22 source "$TESTKIT_ROOT/library/helper_methods.sh"
23 #source "$TESTKIT_ROOT/library/runner_functions.sh"
24 source "$TESTKIT_ROOT/library/security_management.sh"
25
26 ####
27
28 if [ $# -lt 7 ]; then
29   echo "this script needs 7 parameters:"
30   echo "1: signing cert PFX file to base new cert on."
31   echo "2: the password for the signing cert PFX."
32   echo "3: the alias of the key to use within the signing PFX."
33   echo "4: output file to create with new certificate in PFX format."
34   echo "5: password for new certificate PFX file."
35   echo "6: alias for the certificate within the PFX file."
36   echo "7: Common Name (CN) of the identity signified by the new certificate."
37   echo
38   echo "This is an example run using a signing cert for a container:"
39   echo
40   echo 'bash $TESTKIT_ROOT/library/gen_cert_from_ca.sh signing-cert.pfx signer signing-cert $HOME/new_cert.pfx myPassword certalias "Fred Powers"'
41   exit 1
42 fi
43
44 signing_cert="$1"; shift
45 signing_passwd="$1"; shift
46 signing_alias="$1"; shift
47 output_file="$1"; shift
48 output_passwd="$1"; shift
49 output_alias="$1"; shift
50 output_cn="$1"; shift
51
52 create_pfx_using_CA "$signing_cert" "$signing_passwd" "$signing_alias" "$output_file" "$output_passwd" "$output_alias" "$output_cn"
53 check_if_failed "generating '$output_file' from '$signing_cert'"
54
55 echo "New certificate was generated into: $output_file"
56
57 exit 0
58