Repository navigation
gradle: use cacert for the google-api-client trust store - #576575
Conversation
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)
britter
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
❓ 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?
There was a problem hiding this comment.
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.
|
Successfully created backport PR for |
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.0GoogleNetHttpTransport.newTrustedTransport(), which always loads the bundledgoogle.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 --rebuildgives an identical jar. A realgcs://repository was not tested (it needs GCP credentials).Related to: #576485
Related to: #576542
Assisted-by: Claude Code (claude-opus-5)
Things done
./result/bin/.nixpkgs-reviewon this PR. See nixpkgs-review usage.passthru.tests.