Skip to content

jabref: generate truststore.jks from cacert - #577763

Open
irgolic wants to merge 1 commit into
NixOS:masterfrom
irgolic:cacert/jabref
Open

irgolic wants to merge 1 commit into
NixOS:masterfrom
irgolic:cacert/jabref

Conversation

@irgolic

@irgolic irgolic commented Oct 23, 2026

Copy link
Copy Markdown
Member

Part of #576543.

JabRef has a bundled Java trust store, jablib/src/main/resources/ssl/truststore.jks. At start, jabgui and jabkit copy this file to ~/.local/share/jabref/ssl/truststore.jks when there is no copy. Then JabRef uses this copy together with the trust store of its JRE. This change replaces the file in postPatch with a trust store that jre-generate-cacerts makes from the ca-bundle.crt file of cacert, with the password changeit of JabRef. The build puts the file into share/java/jabref/resources/main/ssl and into the four -all.jar files in lib. A user who has a copy keeps the previous trust store, because JabRef copies the file only when there is no copy.

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 harness builds JabRef from source with --force-build, and for this build, approximately 12 GB of space in the build directory is necessary.

nix run github:irgolic/nix-cacert-harness -- jabref --pr <this PR> --emudhra --force-build
Harness output: jabref
$ nix run github:irgolic/nix-cacert-harness -- jabref --base 8915027df75d0403ef013dd0cbf09ff3c602fd03 --after github:irgolic/nixpkgs/bc5739d29840b1a625dbe557acfb1a512737ebee --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 jabref
before: 8915027df75d0403ef013dd0cbf09ff3c602fd03   after: github:irgolic/nixpkgs/bc5739d29840b1a625dbe557acfb1a512737ebee
before ok (0 built, 3s)
        drv /nix/store/…-jabref-6.0-alpha.6.drv
after  ok (0 built, 3s)
        drv /nix/store/…-jabref-6.0-alpha.6.drv

| output:path | before | after |
|---|---|---|
| out:/share/java/jabref/resources/main/ssl/truststore.jks | keystore 89 certs: 35 not in cacert, 15 in cacert but not for TLS, 79 cacert TLS roots missing [no-password]; scanner: AAA | keystore 118 certs == cacert [needs-password(changeit)] |

inside archives (scanner only; a symlink in the installed output cannot reach them, issue #576542 class):
  before out:/lib/jabgui-6.0-alpha.6-all.jar!ssl/truststore.jks  roots=81 trusts AAA Certificate Services
  before out:/lib/jabgui-6.0-alpha.6-all.jar!native/lib/osx-aarch64/cpu/libtokenizers.dylib  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  before out:/lib/jabgui-6.0-alpha.6-all.jar!native/lib/win-x86_64/cpu/tokenizers.dll  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  before out:/lib/jabkit-6.0-alpha.6-all.jar!ssl/truststore.jks  roots=81 trusts AAA Certificate Services
  before out:/lib/jabkit-6.0-alpha.6-all.jar!native/lib/osx-aarch64/cpu/libtokenizers.dylib  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  before out:/lib/jabkit-6.0-alpha.6-all.jar!native/lib/win-x86_64/cpu/tokenizers.dll  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  before out:/lib/jabls-cli-6.0-alpha.6-all.jar!ssl/truststore.jks  roots=81 trusts AAA Certificate Services
  before out:/lib/jabls-cli-6.0-alpha.6-all.jar!native/lib/osx-aarch64/cpu/libtokenizers.dylib  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  before out:/lib/jabls-cli-6.0-alpha.6-all.jar!native/lib/win-x86_64/cpu/tokenizers.dll  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  before out:/lib/jabsrv-cli-6.0-alpha.6-all.jar!ssl/truststore.jks  roots=81 trusts AAA Certificate Services
  before out:/lib/jabsrv-cli-6.0-alpha.6-all.jar!native/lib/osx-aarch64/cpu/libtokenizers.dylib  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  before out:/lib/jabsrv-cli-6.0-alpha.6-all.jar!native/lib/win-x86_64/cpu/tokenizers.dll  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  after  out:/lib/jabgui-6.0-alpha.6-all.jar!ssl/truststore.jks  roots=115 trusts emSign Root CA - G1
  after  out:/lib/jabgui-6.0-alpha.6-all.jar!native/lib/osx-aarch64/cpu/libtokenizers.dylib  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  after  out:/lib/jabgui-6.0-alpha.6-all.jar!native/lib/win-x86_64/cpu/tokenizers.dll  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  after  out:/lib/jabkit-6.0-alpha.6-all.jar!ssl/truststore.jks  roots=115 trusts emSign Root CA - G1
  after  out:/lib/jabkit-6.0-alpha.6-all.jar!native/lib/osx-aarch64/cpu/libtokenizers.dylib  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  after  out:/lib/jabkit-6.0-alpha.6-all.jar!native/lib/win-x86_64/cpu/tokenizers.dll  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  after  out:/lib/jabls-cli-6.0-alpha.6-all.jar!ssl/truststore.jks  roots=115 trusts emSign Root CA - G1
  after  out:/lib/jabls-cli-6.0-alpha.6-all.jar!native/lib/osx-aarch64/cpu/libtokenizers.dylib  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  after  out:/lib/jabls-cli-6.0-alpha.6-all.jar!native/lib/win-x86_64/cpu/tokenizers.dll  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  after  out:/lib/jabsrv-cli-6.0-alpha.6-all.jar!ssl/truststore.jks  roots=115 trusts emSign Root CA - G1
  after  out:/lib/jabsrv-cli-6.0-alpha.6-all.jar!native/lib/osx-aarch64/cpu/libtokenizers.dylib  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  after  out:/lib/jabsrv-cli-6.0-alpha.6-all.jar!native/lib/win-x86_64/cpu/tokenizers.dll  roots=137 trusts emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1

cacert in runtime closure (before): no
cacert in runtime closure (after): no
CAs trusted before but not trusted for TLS by cacert (50 total), e.g.:
  - CN=AAA Certificate Services, O=Comodo CA Limited, L=Salford, ST=Greater Manchester, C=GB
  - 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=AffirmTrust Commercial, O=AffirmTrust, C=US
  - CN=AffirmTrust Networking, O=AffirmTrust, C=US
  - CN=AffirmTrust Premium ECC, O=AffirmTrust, C=US
  - CN=AffirmTrust Premium, O=AffirmTrust, C=US
VERDICT jabref: FIXED: before trusted CAs outside cacert; after: 1 store(s) == cacert, none with extra CAs (+ bundles inside archives remain, see above)

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:/share/java/jabref/resources/main/ssl/truststore.jks | keystore: accepted 7/14 (g3: 0/7, aaa: 7/7, noct: 1/2) | keystore (password changeit): accepted 0/14 |
inside archives (zip members, extracted):
| out:/lib/jabgui-6.0-alpha.6-all.jar!native/lib/osx-aarch64/cpu/libtokenizers.dylib | n/a (pem: no certificates readable) | n/a (pem: no certificates readable) |
| out:/lib/jabgui-6.0-alpha.6-all.jar!native/lib/win-x86_64/cpu/tokenizers.dll | n/a (pem: no certificates readable) | n/a (pem: no certificates readable) |
| out:/lib/jabgui-6.0-alpha.6-all.jar!ssl/truststore.jks | keystore: accepted 7/14 (g3: 0/7, aaa: 7/7, noct: 1/2) | keystore (password changeit): accepted 0/14 |
| out:/lib/jabkit-6.0-alpha.6-all.jar!native/lib/osx-aarch64/cpu/libtokenizers.dylib | n/a (pem: no certificates readable) | n/a (pem: no certificates readable) |
| out:/lib/jabkit-6.0-alpha.6-all.jar!native/lib/win-x86_64/cpu/tokenizers.dll | n/a (pem: no certificates readable) | n/a (pem: no certificates readable) |
| out:/lib/jabkit-6.0-alpha.6-all.jar!ssl/truststore.jks | keystore: accepted 7/14 (g3: 0/7, aaa: 7/7, noct: 1/2) | keystore (password changeit): accepted 0/14 |
| out:/lib/jabls-cli-6.0-alpha.6-all.jar!native/lib/osx-aarch64/cpu/libtokenizers.dylib | n/a (pem: no certificates readable) | n/a (pem: no certificates readable) |
| out:/lib/jabls-cli-6.0-alpha.6-all.jar!native/lib/win-x86_64/cpu/tokenizers.dll | n/a (pem: no certificates readable) | n/a (pem: no certificates readable) |
| out:/lib/jabls-cli-6.0-alpha.6-all.jar!ssl/truststore.jks | keystore: accepted 7/14 (g3: 0/7, aaa: 7/7, noct: 1/2) | keystore (password changeit): accepted 0/14 |
| out:/lib/jabsrv-cli-6.0-alpha.6-all.jar!native/lib/osx-aarch64/cpu/libtokenizers.dylib | n/a (pem: no certificates readable) | n/a (pem: no certificates readable) |
| out:/lib/jabsrv-cli-6.0-alpha.6-all.jar!native/lib/win-x86_64/cpu/tokenizers.dll | n/a (pem: no certificates readable) | n/a (pem: no certificates readable) |
| out:/lib/jabsrv-cli-6.0-alpha.6-all.jar!ssl/truststore.jks | keystore: accepted 7/14 (g3: 0/7, aaa: 7/7, noct: 1/2) | keystore (password changeit): accepted 0/14 |
VERDICT jabref emudhra: FIXED: before accepted 7/14 compromised eMudhra chains (g3: 0/7, aaa: 7/7, noct: 1/2); after 0/14

[2/2] live eMudhra test hosts: needs network, NOT reproducible offline
==================================================================
LIVE jabref: needs network; NOT reproducible offline (the static and behavioral checks are)
before: 8915027df75d0403ef013dd0cbf09ff3c602fd03   after: github:irgolic/nixpkgs/bc5739d29840b1a625dbe557acfb1a512737ebee
shim: shims/jabref.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-jabref
after  ok (0 package drvs built, 3s)
        wrapper /nix/store/…-ca-live-jabref
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      REFUSED        | Exception in thread "main" javax.net.ssl.SSLHandshakeException: (certificate_unknown) PKIX path building failed: sun.security.provider.certpath.SunCertPathBuild
  before dv-g3b-aaa  CONNECTED      | OK status=200 cipher=TLS_AES_256_GCM_SHA384
  before dv-g3c      REFUSED        | Exception in thread "main" javax.net.ssl.SSLHandshakeException: (certificate_unknown) PKIX path building failed: sun.security.provider.certpath.SunCertPathBuild
  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

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

The harness tests the package with the certificate chains of the eMudhra incident, from https://emudhra.we-have-a-problem.com/ (only the certificates, not the keys). Before this change, each copy of the bundled trust store accepts 7 of the 14 chains (accepted 7/14). Thus, it accepts the eMudhra intermediate certificates through the Sectigo cross-sign by AAA Certificate Services. After this change, each copy accepts no chain (accepted 0/14). The tokenizers libraries in the .jar files are for macOS and Windows only, and this change does not change them. In the second part of the output, a small Java test on the JRE of JabRef uses TrustStoreManager.createTruststoreFileIfNotExist, as the launchers do. Then it sends one request to each of four test servers. Before this change, the test connects to the two servers with the AAA chain. After this change, the test connects to no server.

Things done

Assisted-by: Claude Code (Claude Fable 5.1)
Assisted-by: Claude Code (Claude Opus 5.5)
@irgolic irgolic added the 1.severity: security Issues which raise a security issue, or PRs that fix one label Oct 23, 2026
@nixpkgs-ci
nixpkgs-ci Bot requested a review from linsui October 23, 2026 11:16
@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. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. llm-assisted Contributions that include code generation with LLMs labels Oct 23, 2026
@linsui

linsui commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Would it be better to make jabref trust a system keystore instead so that can be updated without rebuilding jabref?

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 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. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. llm-assisted Contributions that include code generation with LLMs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants