Repository navigation
openjdk: generate cacerts from cacert for JDK 11+ - #576518
Conversation
cacert has no Java keystore output. Point at jre-generate-cacerts, as openjdk uses (NixOS/nixpkgs#576518). Assisted-by: Claude Code (claude-opus-5)
Infinidoge
left a comment
There was a problem hiding this comment.
This feels like something that should have a build option, instead of being something we do unilaterally. However, considering that Java 8 doesn't have a build option to toggle it, this is fine as is.
| '' | ||
| # Build lib/security/cacerts from cacert instead of the bundled CA list. | ||
| # It goes into the java.base jmod, so jlink images also get it. | ||
| # Like upstream, write a PKCS12 store without a password: the JDK opens | ||
| # cacerts without one, and cannot read password-protected certificates. | ||
| + lib.optionalString atLeast11 '' | ||
| mkdir "$NIX_BUILD_TOP/cacerts-gen" | ||
| pushd "$NIX_BUILD_TOP/cacerts-gen" | ||
| JAVA_TOOL_OPTIONS="-Dkeystore.pkcs12.certProtectionAlgorithm=NONE -Dkeystore.pkcs12.macAlgorithm=NONE" \ | ||
| ${jre-generate-cacerts} ${jdk-bootstrap'.home}/bin/keytool ${cacert}/etc/ssl/certs/ca-bundle.crt | ||
| popd | ||
| configureFlags+=("--with-cacerts-file=$NIX_BUILD_TOP/cacerts-gen/cacerts") |
There was a problem hiding this comment.
It feels like $NIX_BUILD_TOP/cacerts-gen should be its own variable so it isn't repeated here, but adding a variable feels a bit extra, so it's probably fine as is.
JDK 8 already builds its cacerts from cacert. JDK 11 and later shipped the CA list that comes with the OpenJDK source. That list does not get the cacert updates, for example the removal of distrusted roots. Generate the keystore with the bootstrap keytool before configure and give it to --with-cacerts-file. The file goes into the java.base jmod, so jlink images such as jre_minimal also use it. Write a PKCS12 store without a password, like upstream. The JDK opens cacerts without a password, so it cannot read certificates that a password protects. Assisted-by: Claude Code (claude-opus-5)
df849ec to
b1e20b2
Compare
|
nixpkgs master has the big cacert rebuild now, so adding this should be insignificant in terms of additional rebuild work. |
There was a problem hiding this comment.
The PR's base branch is set to master, but this PR causes 2079 rebuilds.
It is therefore considered a mass rebuild.
Please change the base branch to the right base branch for your changes (probably staging).
yes, intentional, special situation now
|
Successfully created backport PR for |
JDK 8 already builds its cacerts from cacert. JDK 11 and later shipped the CA list that comes with the OpenJDK source. That list does not get the cacert updates, for example the removal of distrusted roots.
Generate the keystore with the bootstrap keytool before configure and give it to --with-cacerts-file. The file goes into the java.base jmod, so jlink images such as jre_minimal also use it.
Write a PKCS12 store without a password, like upstream. The JDK opens cacerts without a password, so it cannot read certificates that a password protects.
Closes: #210241
Related to: #576485
Related to: #576543
This reverses 5a53b98 ("openjdk10: Use included cacerts", 2018). That commit gave no reason. Since then the bundled list has gone stale between JDK releases, and the eMudhra distrust shows the cost: the JDK 11+ store still holds
emSign ECC Root CA - G3andAAA Certificate Services.Tested on x86_64-linux with
openjdk21_headless(same diff on master):keytool -list -cacertsopens without a password: PKCS12, 118 entries. Their SHA-256 fingerprints match the 118 server-auth roots of cacert 3.131.1. AAA (email trust only in cacert) and emSign ECC Root CA - G3 are gone.lib/security/cacerts.JAVAX_NET_SSL_TRUSTSTOREset to a store without the needed root it fails with "PKIX path building failed".openjdk11,openjdk17_headless,openjdk21,openjdk25andjre_minimalinstantiate on staging.Note: the cacerts format cannot carry the NSS "distrust after" dates, so those are lost, as they already are for JDK 8.
Assisted-by: Claude Code (claude-opus-5)
Things done
./result/bin/.nixpkgs-reviewon this PR. See nixpkgs-review usage.passthru.tests.