Last active
July 24, 2017 15:22
-
-
Save breun/9816e784e166d29c81f552f8fcf1a081 to your computer and use it in GitHub Desktop.
Add Java Cryptography Extension (JCE) to all Java 8 Development Kit installations on macOS
This file contains 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 symlinks the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files | |
# to all Java 8 Development Kit installations on macOS. The original policy files are backed up as *.backup. | |
# | |
# 1. Download: http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html | |
# 2. Unpack the zip file somewhere, e.g. /Library/Java/JavaCryptographyExtensions8 | |
# 3. Put this script in the directory where you put the unpacked files | |
# 4. Run 'sudo ./install.sh' to make the cryptography extensions available to all JDK 8 installations | |
# | |
# Just re-run this script after adding a new JDK 8 installation. | |
# | |
# Test: javax.crypto.Cipher.getMaxAllowedKeyLength("AES") should return 2147483647 (Integer.MAX_VALUE) instead of 128. | |
JDK_ROOT=/Library/Java/JavaVirtualMachines | |
JAVA_CRYPTOGRAPHY_EXTENSIONS_DIR=`pwd` | |
function symlink_crypto_jar_with_backup { | |
DIR=$1 | |
FILE=$2 | |
cd $DIR | |
if [ ! -h $FILE ]; then | |
mv $FILE $FILE.backup | |
fi | |
ln -sf $JAVA_CRYPTOGRAPHY_EXTENSIONS_DIR/$FILE | |
} | |
for JDK8 in $JDK_ROOT/jdk1.8*.jdk; do | |
for JAR in US_export_policy.jar local_policy.jar; do | |
symlink_crypto_jar_with_backup $JDK8/Contents/Home/jre/lib/security $JAR | |
done | |
echo Enabled Java Cryptography Extensions for JDK 8: `basename $JDK8` | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment