ancient-stone-50795
07/22/2015, 7:02 PM#!/bin/bash
#
# Echos the name of a pem file of CA certs. Creates the
# file if needed.
#
# Linux: There's already a file in /etc
# Mac: Extract the SSL CA certificates from the keychain
set -e
PANTS_BOOTSTRAPDIR=~/.cache/pants
UNAME_S=$(uname -s)
case ${UNAME_S} in
Darwin)
mkdir -p ${PANTS_BOOTSTRAPDIR}
CACERTS_PEM=${PANTS_BOOTSTRAPDIR}/cacerts.pem
security find-certificate -a -p /Library/Keychains/System.keychain > ${CACERTS_PEM}
security find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain >> ${CACERTS_PEM}
;;
Linux)
CACERTS_PEM="/etc/pki/tls/certs/ca-bundle.crt"
;;
*)
echo "*** ${UNAME_S} not supported by this script!" 1>&2
exit 1
esac
echo ${CACERTS_PEM}