cert-manager / trust-manager

trust-manager is an operator for distributing trust bundles across a Kubernetes cluster.
https://cert-manager.io/docs/projects/trust-manager/
Apache License 2.0
233 stars 64 forks source link

Fix passwordless pkcs12 files for Java #307

Closed SgtCoDFish closed 4 months ago

SgtCoDFish commented 4 months ago

In #296 user discovered that Java's keytool was unable to read PKCS#12 files generated by trust-manager which had no password set. We've not dug into why, but presumably keytool's implementation treats an empty password the same as a missing password somehow.

This wasn't caught in tests because our PKCS#12 library can parse the resulting files just fine.

By changing to use the "passwordless" encoder when no password is present, we can create files which both our tests and keytool can read. It's possible that some other tools can't handle the passwordless encoder and could break, but Java is (anecdotally) what we'd expect to be the largest consumer of PKCS#12 trust stores, so we'll optimise for that.

No test is provided here because keytool requires a JRE and it feels like too much to add a JRE to our test environment just for this. Instead, I've attached fixed-pkcs12.zip which contains examples of fixed PKCS#12 files created using this branch. The password for the password-protected example is abc123

Closes #296

jetstack-bot commented 4 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: erikgb

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/cert-manager/trust-manager/blob/main/OWNERS)~~ [erikgb] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
SgtCoDFish commented 4 months ago

Thanks for the fast review Erik ❤️