Skip to content

Instantly share code, notes, and snippets.

@LukeDefeo
Created November 22, 2017 14:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save LukeDefeo/f4463ffeff4629183f94326deed75169 to your computer and use it in GitHub Desktop.
Save LukeDefeo/f4463ffeff4629183f94326deed75169 to your computer and use it in GitHub Desktop.
Extracts all certificates from the mac os certificate store / key chain and imports them into the key chain of your Java installation
#!/bin/bash
#this script should pull all root CAs from the mac os keychain and add them to the jre's keystore
#Comes with absolutely no warranty and all the usual disclaimers
mkdir temp-extract
cd temp-extract
keystore=$JAVA_HOME/jre/lib/security/cacerts
echo "making backup of keystore $keystore to ~/keystore.backup"
set -e -o pipefail
cp $keystore ~/keystore.backup
security find-certificate -a -p | split -p "-----BEGIN CERTIFICATE-----"
set +e
for f in *;
do
echo "importing cert $f "
keytool -importcert -noprompt -keystore ${keystore} -storepass changeit -alias $f -file $f;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment