Java cacerts From OS Trust Bundle

One of the vexing things about Java is that it uses its own cacerts trust store when the OS has its own updated and configurable trust store. In Windows, there’s a solution. Add a flag to set a system property

-Djavax.net.ssl.trustStoreType=Windows-ROOT

Linux folks? There actually is a way to use the OS trust store. It’s just not so clear and easy. There is a package which uses the system CA store as the source of truth and creates a hook to regenerate the JDK’s cacerts from it whenever the system bundle is rebuilt. The JDK’s cacerts path is a symlink into the generated file, so Java reads whatever the last rebuild produced. Nothing syncs continuously. The sync happens only when the rebuild command runs.

Debian/Ubuntu

  • Source: /usr/local/share/ca-certificates/*.crt (your additions) plus the packaged roots in /usr/share/ca-certificates/.
  • Rebuild: update-ca-certificates combines these into /etc/ssl/certs/ca-certificates.crt and runs the hooks in /etc/ca-certificates/update.d/.
  • Java hook: the ca-certificates-java package installs a hook that uses the JDK’s keytool to build /etc/ssl/certs/java/cacerts from the system bundle.
  • Link: the JDK’s lib/security/cacerts is managed by update-alternatives and points to /etc/ssl/certs/java/cacerts.
  • Triggers: running update-ca-certificates (manually, or by package install/upgrade or your config management), and installing or upgrading ca-certificates-java.

RHEL/Fedora/CentOS

  • Source: /etc/pki/ca-trust/source/anchors/ (your additions), plus vendor anchors in /usr/share/pki/ca-trust-source/.
  • Rebuild: update-ca-trust extract uses p11-kit to generate bundles under /etc/pki/ca-trust/extracted/, including a java/cacerts file.
  • Link: /etc/pki/java/cacerts points to the generated extracted/java/cacerts, and the JDK’s cacerts links to that.
  • Triggers: running update-ca-trust (manually, or by RPM scriptlets when the ca-certificates package updates).

Leave a Reply

Your email address will not be published. Required fields are marked *