Skip to content

corretto: generate cacerts from cacert - #577594

Merged
r-vdp merged 1 commit into
NixOS:masterfrom
irgolic:cacert/corretto
Oct 27, 2026
Merged

r-vdp merged 1 commit into
NixOS:masterfrom
irgolic:cacert/corretto

Conversation

@irgolic

@irgolic irgolic commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Part of #576543.

nixpkgs builds the Corretto JDKs, corretto11 to corretto25, from source with dontConfigure = true. Thus, the preConfigure step of openjdk, which makes lib/security/cacerts from cacert (#576518), is not done. Before this change, the Java trust store of Corretto has 146 certificates, and 43 of them are not in cacert. This change makes a new cacerts from the cacert bundle with jre-generate-cacerts in preBuild. Then it adds --with-cacerts-file for this file to the start of corretto.extra_config. build.gradle puts corretto.extra_config after the options of Corretto, and configure uses the last option. Thus, this option comes after the option of Corretto, and an option in extraConfig comes after this option. The log of configure shows checking for cacerts file... /build/cacerts-gen/cacerts.

Warning

AI Disclosure: Claude Code made the code change, the commit message and the first version of this pull request description. Claude Code used Claude Fable 5.1 and Claude Opus 5.5. I examined all of this work. Claude Code also wrote all of nix-cacert-harness. This pull request description is written in ASD-STE100 (Simplified Technical English), examined with memelint in strict mode.

Test

nix-cacert-harness examines the package before and after this change. A local copy of nixpkgs is not necessary. The other three Corretto versions get the same change from mk-corretto.nix. The harness builds Corretto from source a maximum of two times, and each build is approximately 25 minutes long. Without --force-build, the harness does not do these long builds.

nix run github:irgolic/nix-cacert-harness -- corretto21 --pr 577594 --emudhra --force-build
Harness output: corretto21
$ nix run github:irgolic/nix-cacert-harness -- corretto21 --base 8915027df75d0403ef013dd0cbf09ff3c602fd03 --after github:irgolic/nixpkgs/e3f41e9b3cefd787780fa744e09ebeff8622c153 --emudhra --force-build
[1/2] static check + eMudhra chains: offline, reproducible
base (before) = 8915027df75d0403ef013dd0cbf09ff3c602fd03
reference: fprs4zi8r6227x12qbsd1grvfrpz6201-nss-cacert-3.131.1 TLS roots=118 all=169
==================================================================
ATTR corretto21
before: 8915027df75d0403ef013dd0cbf09ff3c602fd03   after: github:irgolic/nixpkgs/e3f41e9b3cefd787780fa744e09ebeff8622c153
before ok (0 built, 1s)
        drv /nix/store/…-corretto21-21.0.9.11.1.drv
after  ok (1 built, 1222s)
        drv /nix/store/…-corretto21-21.0.9.11.1.drv

| output:path | before | after |
|---|---|---|
| out:/lib/corretto/lib/security/cacerts | keystore 146 certs: 43 not in cacert, 19 in cacert but not for TLS, 34 cacert TLS roots missing [no-password]; scanner: AAA,ECC G3 | keystore 118 certs == cacert [no-password] |

cacert in runtime closure (before): no
cacert in runtime closure (after): no
CAs trusted before but not trusted for TLS by cacert (62 total), e.g.:
  - CN=AAA Certificate Services, O=Comodo CA Limited, L=Salford, ST=Greater Manchester, C=GB
  - CN=emSign ECC Root CA - C3, O=eMudhra Inc, OU=emSign PKI, C=US
  - CN=emSign ECC Root CA - G3, O=eMudhra Technologies Limited, OU=emSign PKI, C=IN
  - CN=emSign Root CA - C1, O=eMudhra Inc, OU=emSign PKI, C=US
  - CN=emSign Root CA - G2, O=eMudhra Technologies Limited, OU=emSign PKI, C=IN
  - C=DE, O=Atos, CN=Atos TrustedRoot 2011
  - CN=AddTrust External CA Root, OU=AddTrust External TTP Network, O=AddTrust AB, C=SE
  - CN=AddTrust Qualified CA Root, OU=AddTrust TTP Network, O=AddTrust AB, C=SE
  - CN=Autoridad de Certificacion Firmaprofesional CIF A62634068, C=ES
  - CN=Certigna, O=Dhimyotis, C=FR
  - CN=Certum CA, O=Unizeto Sp. z o.o., C=PL
VERDICT corretto21: FIXED: before trusted CAs outside cacert; after: 1 store(s) == cacert, none with extra CAs

eMudhra chains (--emudhra; offline and reproducible): the 14 chains in fixtures/emudhra,
each leaf verified against each store (openssl verify -purpose sslserver, at 2026-10-23):
| output:path | before | after |
|---|---|---|
| out:/lib/corretto/lib/security/cacerts | keystore: accepted 14/14 (g3: 7/7, aaa: 7/7, noct: 2/2) | keystore: accepted 0/14 |
VERDICT corretto21 emudhra: FIXED: before accepted 14/14 compromised eMudhra chains (g3: 7/7, aaa: 7/7, noct: 2/2); after 0/14

[2/2] live eMudhra test hosts: needs network, NOT reproducible offline
==================================================================
LIVE corretto21: needs network; NOT reproducible offline (the static and behavioral checks are)
before: 8915027df75d0403ef013dd0cbf09ff3c602fd03   after: github:irgolic/nixpkgs/e3f41e9b3cefd787780fa744e09ebeff8622c153
shim: shims/java-runtime.nix   hosts: https://<host>-emudhra.we-have-a-problem.com/, one request per host per side, 10s timeout
before ok (0 package drvs built, 3s)
        wrapper /nix/store/…-ca-live-corretto21
after  ok (0 package drvs built, 4s)
        wrapper /nix/store/…-ca-live-corretto21
system store: visible: /etc/ssl/certs/ca-certificates.crt -> nss-cacert-3.126/etc/ssl/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt -> nss-cacert-3.126/etc/ssl/certs/ca-bundle.crt
              rejects every served chain, so it cannot make a cell CONNECTED
              but it holds the root of dv-g3b,dv-g3b-aaa,dv-g3c,dv-g3c-aaa with a trust rule that REJECTS it (OpenSSL "certificate rejected"):
              a program that loads it next to its own store (OpenSSL's default paths, e.g. excon) is
              REFUSED there whatever its own store says; --no-system-store shows the package's store alone
control dv-g3b: ok: HTTP 200, served chain == fixtures/emudhra/dv-g3b-emudhra.we-have-a-problem.com.pem (3 certs, valid for the host up to emSign ECC Root CA - G3), stock cacert rejects it
control dv-g3b-aaa: ok: HTTP 200, served chain == fixtures/emudhra/dv-g3b-aaa-emudhra.we-have-a-problem.com.pem (2 certs, valid for the host up to AAA Certificate Services), stock cacert rejects it
control dv-g3c: ok: HTTP 200, served chain == fixtures/emudhra/dv-g3c-emudhra.we-have-a-problem.com.pem (3 certs, valid for the host up to emSign ECC Root CA - G3), stock cacert rejects it
control dv-g3c-aaa: ok: HTTP 200, served chain == fixtures/emudhra/dv-g3c-aaa-emudhra.we-have-a-problem.com.pem (2 certs, valid for the host up to AAA Certificate Services), stock cacert rejects it
  before dv-g3b      CONNECTED      | OK status=200 cipher=TLS_AES_256_GCM_SHA384
  before dv-g3b-aaa  CONNECTED      | OK status=200 cipher=TLS_AES_256_GCM_SHA384
  before dv-g3c      CONNECTED      | OK status=200 cipher=TLS_AES_256_GCM_SHA384
  before dv-g3c-aaa  CONNECTED      | OK status=200 cipher=TLS_AES_256_GCM_SHA384
  after  dv-g3b      REFUSED        | Exception in thread "main" javax.net.ssl.SSLHandshakeException: (certificate_unknown) PKIX path building failed: sun.security.provider.certpath.SunCertPathBuild
  after  dv-g3b-aaa  REFUSED        | Exception in thread "main" javax.net.ssl.SSLHandshakeException: (certificate_unknown) PKIX path building failed: sun.security.provider.certpath.SunCertPathBuild
  after  dv-g3c      REFUSED        | Exception in thread "main" javax.net.ssl.SSLHandshakeException: (certificate_unknown) PKIX path building failed: sun.security.provider.certpath.SunCertPathBuild
  after  dv-g3c-aaa  REFUSED        | Exception in thread "main" javax.net.ssl.SSLHandshakeException: (certificate_unknown) PKIX path building failed: sun.security.provider.certpath.SunCertPathBuild

corretto21  (live; before 8915027df75d0403ef013dd0cbf09ff3c602fd03, after github:irgolic/nixpkgs/e3f41e9b3cefd787780fa744e09ebeff8622c153)
         | dv-g3b         | dv-g3b-aaa     | dv-g3c         | dv-g3c-aaa
before   | CONNECTED      | CONNECTED      | CONNECTED      | CONNECTED
after    | REFUSED        | REFUSED        | REFUSED        | REFUSED
VERDICT corretto21 live: PASS: before CONNECTED to 4/4 host(s) serving a compromised eMudhra chain (dv-g3b,dv-g3b-aaa,dv-g3c,dv-g3c-aaa); after REFUSED on all 4

The harness tests the package with the 14 certificate chains of the eMudhra incident, from https://emudhra.we-have-a-problem.com/ (only the certificates, not the keys). Before this change, the trust store of Corretto accepts all 14 chains (accepted 14/14). Thus, it accepts the eMudhra intermediate certificates through emSign ECC Root CA - G3 and through the Sectigo cross-sign by AAA Certificate Services. After this change, the trust store accepts no chain (accepted 0/14). In the second part of the output, a small Java test sends one request to each of four test servers. The test uses HttpsURLConnection and the default trust store. Before this change, the test connects to all four servers. After this change, the test connects to no server. The harness compares the certificates by their SHA-256 fingerprints, because jre-generate-cacerts does not keep the usual aliases.

Things done

Assisted-by: Claude Code (Claude Fable 5.1)
Assisted-by: Claude Code (Claude Opus 5.5)
@zimbatm zimbatm mentioned this pull request Oct 23, 2026
28 of 37 tasks
@nixpkgs-ci
nixpkgs-ci Bot requested a review from rollf October 23, 2026 01:08
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. llm-assisted Contributions that include code generation with LLMs 6.topic: java Including JDK, tooling, other languages, other VMs labels Oct 23, 2026
@irgolic irgolic added the 1.severity: security Issues which raise a security issue, or PRs that fix one label Oct 23, 2026

@rollf rollf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for you looking into this. I am going to approve this because I don't want to further hinder merging this. However, can you please implement my suggested changes?

Comment on lines +140 to +143
pushd "$NIX_BUILD_TOP/cacerts-gen"
JAVA_TOOL_OPTIONS="-Dkeystore.pkcs12.certProtectionAlgorithm=NONE -Dkeystore.pkcs12.macAlgorithm=NONE" \
${jre-generate-cacerts} ${jdk.home}/bin/keytool ${cacert}/etc/ssl/certs/ca-bundle.crt
popd

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pushd "$NIX_BUILD_TOP/cacerts-gen"
JAVA_TOOL_OPTIONS="-Dkeystore.pkcs12.certProtectionAlgorithm=NONE -Dkeystore.pkcs12.macAlgorithm=NONE" \
${jre-generate-cacerts} ${jdk.home}/bin/keytool ${cacert}/etc/ssl/certs/ca-bundle.crt
popd
(
cd "$NIX_BUILD_TOP/cacerts-gen"
JAVA_TOOL_OPTIONS="-Dkeystore.pkcs12.certProtectionAlgorithm=NONE -Dkeystore.pkcs12.macAlgorithm=NONE" \
${jre-generate-cacerts} ${jdk.home}/bin/keytool ${cacert}/etc/ssl/certs/ca-bundle.crt
)

(untested)

gradleFlagsArray+=(-Pcorretto.extra_config="${extra_config}")
# Finally, *append* nix-corretto-version specific flags. They come last,
# so our --with-cacerts-file (see preBuild) overrides Corretto's own.
gradleFlagsArray+=(-Pcorretto.extra_config="${extra_config} --with-cacerts-file=$NIX_BUILD_TOP/cacerts-gen/cacerts")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gradleFlagsArray+=(-Pcorretto.extra_config="${extra_config} --with-cacerts-file=$NIX_BUILD_TOP/cacerts-gen/cacerts")
gradleFlagsArray+=(-Pcorretto.extra_config="--with-cacerts-file=$NIX_BUILD_TOP/cacerts-gen/cacerts ${extra_config}")

I think the last word should be given to the extra config.

@nixpkgs-ci nixpkgs-ci Bot added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Oct 23, 2026
@irgolic
irgolic marked this pull request as draft October 23, 2026 11:45
@irgolic
irgolic marked this pull request as ready for review October 23, 2026 11:47
@irgolic

irgolic commented Oct 23, 2026

Copy link
Copy Markdown
Member Author

Thanks, I've made the changes you requested.

@r-vdp
r-vdp added this pull request to the merge queue Oct 27, 2026
Merged via the queue into NixOS:master with commit 58c01c4 Oct 27, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.severity: security Issues which raise a security issue, or PRs that fix one 6.topic: java Including JDK, tooling, other languages, other VMs 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. llm-assisted Contributions that include code generation with LLMs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants