Skip to content

Instantly share code, notes, and snippets.

@notmayo
Last active August 27, 2025 06:05
Show Gist options
  • Save notmayo/3a672dff2d1b9b5eb8bcd35536584f09 to your computer and use it in GitHub Desktop.
Save notmayo/3a672dff2d1b9b5eb8bcd35536584f09 to your computer and use it in GitHub Desktop.
Install DoD Root Certs on MacOS - 2025
#!/bin/bash
# Set the directory where certificates will be stored
CERT_DIR="$HOME/DoDCertificates"
# Create the directory if it does not exist
mkdir -p "$CERT_DIR"
# Change to the directory
cd "$CERT_DIR"
# Download the zip file containing DoD root certificates. Replace the placeholder with the actual download command.
echo "Downloading DoD root certificates..."
curl -O "https://dl.dod.cyber.mil/wp-content/uploads/pki-pke/zip/unclass-certificates_pkcs7_DoD.zip"
# Find the most recently modified zip file in the directory
ZIP_FILE=$(ls -t *.zip | head -n 1)
echo "Found zip file: $ZIP_FILE"
# Unzip the downloaded file
echo "Unzipping the downloaded certificates..."
unzip -o "$ZIP_FILE"
# The unzip command might create a new directory. Find the directory containing the .p7b files
CERT_SUBDIR=$(find . -mindepth 1 -maxdepth 1 -type d | head -n 1)
echo "Found certificate directory: $CERT_SUBDIR"
# Change to the directory containing the .p7b files
cd "$CERT_SUBDIR"
# Import .p7b files directly into the keychain
for p7b in *.p7b; do
echo "Importing $p7b into the keychain..."
# Import the .p7b file into the login keychain
security import "$p7b" -k ~/Library/Keychains/login.keychain-db -t cert -f pkcs7
done
echo "DoD root certificates installation completed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment