Forked from LukeDefeo/macos-certificates-to-java-keystore.sh
Last active
January 17, 2024 09:46
-
-
Save asgh/bd3b4f3c26f3f9b180ffed5ebb7486e9 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
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
| #!/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=`/usr/libexec/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