Skip to content

gradle: use cacert for the google-api-client trust store - #576575

Merged
r-vdp merged 2 commits into
NixOS:masterfrom
zimbatm:cacert-gradle
Nov 22, 2026
Merged

r-vdp merged 2 commits into
NixOS:masterfrom
zimbatm:cacert-gradle

Conversation

@zimbatm

@zimbatm zimbatm commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Gradle uses google-api-client 1.34.0 for gcs:// repositories and the GCS build cache. GcsClient calls GoogleNetHttpTransport.newTrustedTransport(). That method trusts only google.p12 from the jar (password notasecret). It does not use the JDK cacerts. The bundled list is from 2022 and does not get cacert updates, for example the eMudhra and Sectigo revocations.

Replace google.p12 with a PKCS12 store made from cacert. Remove google.jks, because no code reads it. The rewritten jar is reproducible.

Gradle's GCS transport (GcsClient.create) calls google-api-client 1.34.0 GoogleNetHttpTransport.newTrustedTransport(), which always loads the bundled google.p12 (password "notasecret", 70 entries including AAA Certificate Services, no ISRG Root X1) and never the JDK cacerts.

Tested on x86_64-linux with a small Java program on Gradle's classpath that calls newTrustedTransport(): the old gradle reaches storage.googleapis.com but fails on letsencrypt.org (PKIX path building failed), which shows the JDK store is ignored; the new gradle 8 and 9 reach both. The new store loads with the same password on JDK 8, 17 and 25. nix build --rebuild gives an identical jar. A real gcs:// repository was not tested (it needs GCP credentials).

Related to: #576485
Related to: #576542

Assisted-by: Claude Code (claude-opus-5)

Things done

Gradle uses google-api-client 1.34.0 for gcs:// repositories and the
GCS build cache. GcsClient calls GoogleNetHttpTransport.newTrustedTransport().
That method trusts only google.p12 from the jar (password notasecret).
It does not use the JDK cacerts. The bundled list is from 2022 and does
not get cacert updates, for example the eMudhra and Sectigo revocations.

Replace google.p12 with a PKCS12 store made from cacert. Remove
google.jks, because no code reads it. The rewritten jar is reproducible.

See NixOS#576542.

Assisted-by: Claude Code (claude-opus-5)
@zimbatm zimbatm added the backport release-26.05 Backport PR automatically label Oct 20, 2026
@nixpkgs-ci
nixpkgs-ci Bot requested review from a team, britter, liff and lorenzleutgeb October 20, 2026 22:34
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 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 20, 2026

@Infinidoge Infinidoge 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.

I would like it if someone with GCP credentials could test this, hopefully someone in @NixOS/java can. However if no one does, I'll merge this after giving time for someone to have the chance

@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 20, 2026

@britter britter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the plan is to have the NixOS cacert store injected, I think this is fine. If we just want to fix the references security issues, replacing the google-api jar with a more recent one that has a fixes itself would be preferable in my opinion.

@r-vdp

r-vdp commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

If the plan is to have the NixOS cacert store injected, I think this is fine. If we just want to fix the references security issues, replacing the google-api jar with a more recent one that has a fixes itself would be preferable in my opinion.

AFAIK, the idea is that for the next security issues where we need to quickly update CA root certs, we can simply bump our cacerts package and have it rebuild all the packages that have built-in CA certs automatically, instead of needing a tracking issue and individual PRs for every such package.

# google-api-client (GCS repositories and build cache) trusts only its bundled google.p12.
# Replace it with a store made from cacert. Nothing reads google.jks.
for jar in $gradleLibexec/lib/plugins/google-api-client-*.jar; do
unzip -l "$jar" com/google/api/client/googleapis/google.p12 >/dev/null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

❓ Instead of patching this inline, would it make sense to add https://github.com/googleapis/google-api-java-client/ as a package to nixpkgs and do the patching there?

@r-vdp r-vdp Nov 22, 2026 •

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.

If you don't mind, I will merge this as is and leave it up to the gradle maintainers to come up with a better fix if they want to.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Addressed in #592051

@tomodachi94 tomodachi94 added the 1.severity: security Issues which raise a security issue, or PRs that fix one label Oct 28, 2026
@r-vdp
r-vdp added this pull request to the merge queue Nov 22, 2026
Merged via the queue into NixOS:master with commit 728c18e Nov 22, 2026
27 checks passed
@nixpkgs-ci

nixpkgs-ci Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Successfully created backport PR for release-26.05:

@github-actions github-actions Bot added the 8.has: port to stable This PR already has a backport to the stable release. label Nov 22, 2026
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 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 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. backport release-26.05 Backport PR automatically llm-assisted Contributions that include code generation with LLMs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants