Skip to content

Instantly share code, notes, and snippets.

View matthogan's full-sized avatar
👽

Matt Hogan matthogan

👽
View GitHub Profile
@matthogan
matthogan / import-rds-certs.sh
Last active August 28, 2018 15:05 — forked from shareefhiasat/import-rds-certs.sh
import RDS certificates to java keystore on alpine / osx
curl https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem > rds-combined-ca-bundle.pem
dos2unix rds-combined-ca-bundle.pem
csplit -sk rds-combined-ca-bundle.pem "%BEGIN CERTIFICATE%0" "/BEGIN CERTIFICATE/" "{$(grep -c 'BEGIN CERTIFICATE' rds-combined-ca-bundle.pem | awk '{print $1 - 2}')}"
KS=rds.jks
rm $KS
for CERT in xx*; do
echo "$CERT"
# extract a human-readable alias from the cert
ALIAS=$(openssl x509 -noout -text -in $CERT |
perl -ne 'next unless /Subject:/; s/.*CN=//; print')