-
-
Save charlesfair/036e9f0b55788034a9b624a43f94072d to your computer and use it in GitHub Desktop.
Enable CAC Authentication on Mac OS X (Mojave)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export CERT_URL='http://iasecontent.disa.mil/pki-pke/Certificates_PKCS7_v5.4_DoD.zip' | |
# Download & Extract DoD root certificates | |
cd ~/Downloads/ | |
curl -LOJ ${CERT_URL} | |
unzip $(basename ${CERT_URL}) | |
cd $(basename ${CERT_URL} .zip) | |
# Convert pem.p7b certs to straight pem and import | |
for item in *.pem.p7b; do | |
TOPDIR=$(pwd) | |
TMPDIR=$(mktemp -d /tmp/$(basename ${item} .p7b).XXXXXX) || exit 1 | |
PEMNAME=$(basename ${item} .p7b) | |
openssl pkcs7 -print_certs -in ${item} -out "${TMPDIR}/${PEMNAME}" | |
cd ${TMPDIR} | |
split -p '^$' ${PEMNAME} | |
rm $(ls x* | tail -1) | |
for cert in x??; do | |
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ${cert} | |
done | |
cd ${TOPDIR} | |
rm -rf ${TMPDIR} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment