Repository navigation
Use PKCS#12 encoder to encode JKS - #603
Conversation
69d798e to
dece7d8
Compare
|
/test pull-trust-manager-integration |
SgtCoDFish
left a comment
There was a problem hiding this comment.
I think this is great, and I'd merge it happily! I've got a bunch of suggestions about the keytool test because I think that'd be a great addition even if it's skipped often - so I'll add a hold in case you want to change anything there
/lgtm
/approve
/hold
| tests := map[string]struct { | ||
| keytool string | ||
| }{ | ||
| "Java 21": { | ||
| keytool: "/usr/lib/jvm/java-21-openjdk-amd64/bin/keytool", | ||
| }, | ||
| "Java 17": { | ||
| keytool: "/usr/lib/jvm/java-17-openjdk-amd64/bin/keytool", | ||
| }, | ||
| "Java 11": { | ||
| keytool: "/usr/lib/jvm/java-11-openjdk-amd64/bin/keytool", | ||
| }, | ||
| "Java 8": { | ||
| keytool: "/usr/lib/jvm/java-8-openjdk-amd64/bin/keytool", | ||
| }, | ||
| } |
There was a problem hiding this comment.
suggestion: I don't know if the differing versions of keytool would meaningfully change this - it's not the same as running different versions of Java AFAIK. Plus, these paths assume amd64 (and so wouldn't work for me)
I'd vote to remove the different versions here and, like in my other suggestion, just run this test if keytool can be found on $PATH.
There was a problem hiding this comment.
it's not the same as running different versions of Java AFAIK.
Important note! Hmmm, then I must find a better way to test this. 🤔
There was a problem hiding this comment.
@SgtCoDFish, I hacked together a test that actually runs Java against a Go HTTP server using a self-signed certificate. And it seems to work on my machine for all the LTS Java versions: 8, 11, 17 and 21. Do you have Java installed? It would be nice if you could also test! 😅
901ac88 to
8647077
Compare
There was a problem hiding this comment.
Haven't been able to test this yet but I'd like to! Thank you for looking into this
There was a problem hiding this comment.
Please do! I am 99% sure this should work fine, and all tests pass on my machine with Java 8, 11, 17 and 21.
There was a problem hiding this comment.
It works on my Windows + WSL2 Ubuntu Linux laptop:
$ sudo apt install openjdk-21-jdk-headless
...
$ go test -v ./pkg/bundle/internal/truststore/...
=== RUN Test_Java_keytool_can_read_JKS
java_test.go:73: combined out:
Keystore type: PKCS12
Keystore provider: SUN
Your keystore contains 3 entries
3c95e845|cn=cmct-test-root,o=cert-manager, Apr 24, 2025, trustedCertEntry,
Certificate fingerprint (SHA-256): 3C:95:E8:45:AC:75:2D:FC:13:A9:8B:71:67:41:7E:89:2D:83:02:BC:0F:FB:48:7F:10:A9:DF:AA:C0:D1:26:73
548b988f|cn=cmct-test-root,o=cert-manager, Apr 24, 2025, trustedCertEntry,
Certificate fingerprint (SHA-256): 54:8B:98:8F:4B:AD:7B:DD:0D:3B:75:23:DE:37:15:4E:E4:7F:28:5E:EE:36:D3:B1:F5:3F:AA:27:20:FC:A3:07
96bcec06|cn=isrg root x1,o=internet security research group,c=us, Apr 24, 2025, trustedCertEntry,
Certificate fingerprint (SHA-256): 96:BC:EC:06:26:49:76:F3:74:60:77:9A:CF:28:C5:A7:CF:E8:A3:C0:AA:E1:1A:8F:FC:EE:05:C0:BD:DF:08:C6
--- PASS: Test_Java_keytool_can_read_JKS (0.22s)
=== RUN Test_Java_can_use_JKS
java_test.go:136: combined out:
Note: TestHTTPConnection.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
java_test.go:168: combined out:
Successfully connected to https://127.0.0.1:42583
917a980 to
3e64a4f
Compare
Signed-off-by: Erik Godding Boye <[email protected]>
wallrj
left a comment
There was a problem hiding this comment.
Thanks @erikgb
@ali-hamza-noor and I have tested the new Java integration tests on Ubuntu Linux and Mac.
Ash has reviewed the code, so I'll approve this, as discussed at the cert-manager standup 2025-04-24.
/approve
/lgtm
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: SgtCoDFish, wallrj The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/unhold |
While working on #486, I think the new API could be greatly simplified by removing explicit support for JKS. And after digging a bit deeper into code, issues and PRs in https://github.com/SSLMate/go-pkcs12, I became convinced that just using this module for trust stores in trust-manager is the way forward. Password-less JKS truststores, which is the new Java default (starting Java 18) is also not supported by our currently used JKS module. Support for it was rejected in pavlo-v-chernykh/keystore-go#37.
In this PR I propose to:
I have added a (skipped) test that can be used to verify that the Java keytool can read the new "JKS" truststores, but it requires paths to installed Java and cannot be enabled in CI.
We should probably also verify that the trust stores are usable by a Java application. I don't know how simple this would be to test, but we could ask the community for help in testing after releasing an alpha release of trust-manager? Maybe we could specifically ask historical contributors of JKS features?