Automatically synchronize company certificates to all JDK installations managed by SDKMAN!
This script eliminates the tedious manual process of re-importing company certificates every time you install a new JDK version. It creates symbolic links from your company's certificate store to each JDK installation, ensuring consistent certificate availability across all versions.
- JDK installations managed by SDKMAN!
- Environment variable
COMPANY_CACERTSset to your company's certificate file path in your shell configuration (.zshrc,.bashrc, or.bash_profile)
Example:
export COMPANY_CACERTS="/path/to/your/company/cacerts"- Make the script executable:
chmod +x jdk-sync-certs.sh- Run the script:
./jdk-sync-certs.shTo verify the script worked correctly, check that the cacerts file is a symbolic link pointing to your company certificate store:
ls -l $(sdk home java 21.0.2-open)/lib/security/cacertsExpected output:
lrwxr-xr-x user group ... cacerts -> /path/to/your/company/cacerts
To run this script automatically every time you install a new JDK with SDKMAN!, add this alias to your shell configuration file:
# Automatically sync certificates after installing a new JDK
sdk-install() {
sdk install "$@" && ~/jdk-sync-certs/jdk-sync-certs.sh
}Now you can use sdk-install java 25-open instead of sdk install java 25-open, and certificates will sync automatically.