Commit b260f0f5 authored by Xueshan Feng's avatar Xueshan Feng
Browse files

added upload_cert_to_aws.sh.

parent 1e42f011
Pipeline #73 skipped
#!/bin/bash
# For AWS ELB, the cert chain file needs to be in reverse order - root cert at the top (the 3rd file)
# Usage: ./upload_cert_to_aws.sh foo.stanford.edu awsprofile
#
# To get arn: aws --profile awsprofile iam get-server-certificate --server-certificate-name=<fqdn>
domain='stanford.edu'
server=$1
awsprofile=$2
if [ "X$server" = "X" ];
then
echo "SSL cert CN name is required. e.g. ./upload-cert-to-aws.sh foo.stanford.edu"
exit 1
fi
if [ "X$awsprofile" = "X" ];
then
echo "AWS profile for authentication is requored."
exit 1
fi
server="${server%%.*}"
domaincert="stanford_edu_cert.cer"
intermcert="stanford_edu_interm.cer"
server_name="$server.$domain"
if [[ -f ${server}_${domaincert} ]] && [[ -f ${server}_$intermcert ]] && [[ -f $server_name.key ]];
then
aws --profile $awsprofile iam upload-server-certificate --server-certificate-name $server_name \
--certificate-body file://${server}_${domaincert} \
--private-key file://$server_name.key --certificate-chain file://${server}_$intermcert
else
echo "one of the files are missing: ${server}_${domaincert}, ${server}_$intermcert, or $server_name.key"
exit 1
fi
exit 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment