Skip to content

Instantly share code, notes, and snippets.

@tomdavidson
Last active May 16, 2016 18:21
Show Gist options
  • Save tomdavidson/13dae1ad261b0bec69371c87abd6304c to your computer and use it in GitHub Desktop.
Save tomdavidson/13dae1ad261b0bec69371c87abd6304c to your computer and use it in GitHub Desktop.
install ssl cert on aws, including creating intermediate for a complete chain
#!/bin/bash
# unofficial bash strict mode
set -euo pipefail
IFS=$'\n\t'
# Run script from dir with both certificate files and the private key
# certificate name on AWS
NAME=$1
# certificate file (crt)
CRT=${2:-$NAME.crt}
# private key file (pem)
KEY=${3:-$NAME.key}
# DigicertCA2 path
CA=${4:-DigiCertCA.crt}
# TrustedRoot path
TR=${5:-TrustedRoot.crt}
# Download certificates on Digicert (Other formats > Individual crt files with
# a .cer extension)
# Generate intermediate cert - WSO2 Api Manager requires it. Intermediate is
# concatenation of CA and Root certs.
(openssl x509 -inform PEM -in $CA; openssl x509 -inform PEM -in $TR) > Intermediate.cer
# Upload to AWS with awscli
aws iam upload-server-certificate \
--server-certificate-name $NAME \
--certificate-body file://$CRT \
--private-key file://$KEY \
--certificate-chain file://Intermediate.cer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment