12 Commits
Author SHA1 Message Date
Nik 3053a19816 Add JCEKS integration tests (#350)
This commit adds tests for the `jceks` package against the
installed JDK's `keytool` CLI. The tests ensure that JCEKS files
created by `keytool` can be read by the package, and vice versa.
These tests are disabled by default and are enabled with the
`-jceks.keytool-tests=true` flag. This commit configures GitHub
Actions to test the package against a wide variety of JDKs.

This commit also restricts GitHub Actions permissions.
2025-08-07 17:33:08 -04:00
Nik fe6d52ce3c Add encoding support to JCEKS package (#349)
This commit adds a JCEKS encoder to the `jceks` package.
Previously, the package was only capable of reading JCEKS files.

Internally, this commmit effectively rewrites the package.

These changes are backward compatible with the previous package API
and thus do not require a new major version. However, there are
several behavioral changes that have the potential to break
existing code that relied on edge cases:

- The package now returns an error when attempting to parse a JCEKS
  file that contains an invalid X.509 certificate (either as a
  trusted certificate entry, or as part of the chain for a private
  key entry). Previously, the package silently ignored these
  certificates. JCEKS files containing invalid certificates are
  invalid, so affected files should be repaired.
- The package now returns an error by default when parsing a JCEKS
  file containing a certificate or private key larger than 20MiB.
  This limit guards against trivial memory exhaustion denial of
  service attacks from malicious files, but the default is very
  generous. Callers that need to parse larger certificates or
  private keys can override the defaults using the new
  `KeyStore.ParseWithOptions` method with appropriate options.

The internal changes to the package introduced by this commit are
substantial. Some of the highlights include:
- Fixed a bug with modified UTF-8 parsing.
- `testdata` is now generated by `go generate`, rather than
  shelling out to `openssl` and `keytool` at unit test time.
- PKCS#5 padding is now removed when parsing.
- Tests are now far more comprehensive, including fuzz tests.
- General code cleanup and linter fixes.
2025-08-07 11:06:42 -04:00
Nik Unger 68183f4853 Add and enforce copyright headers via linter
This commit normalizes copyright headers across the codebase.
2025-07-28 13:05:13 -04:00
Nik Unger 10bbc8cdc1 Fix current linter findings
This commit adds an explicit `golangci-lint` configuration that
simply matches the default linters previously in use, and then
fixes all current linter findings.

Aside from tweaking error message strings, this commit introduces
one externally visible behavior change: PEM data generated from
PKCS#12 files now correctly identifies private key blocks as
`RSA PRIVATE KEY` or `EC PRIVATE KEY`, whereas previously it
generated invalid `PRIVATE KEY` blocks with non-PKCS#8 data.

This commit lays the groundwork for more aggressive linting in the
future, and identifies some additional issues via TODOs.
2025-07-24 12:59:48 -04:00
John Wood 44210f297c Remove ioutil (#289) 2022-08-11 10:59:59 -07:00
Matthew McPherrin e61c2446dc Fix a tiny typo in a comment. 2018-07-06 10:56:49 -07:00
Matthew McPherrin 92f9a2dca9 Don't panic in the JCEKS library
Returns an error instead.
2017-02-02 16:56:48 -08:00
Cedric Staub a7caa8960c Support elliptic curve keys 2016-06-21 17:48:40 -07:00
Cedric Staub 36e3af5e3e Allow certs to be read even if cert sign key usage not set 2016-06-10 15:28:33 -07:00
Cedric Staub 327dcdf884 Support stdin, add examples to readme 2016-06-07 13:48:04 -07:00
Cedric Staub 5adab41e06 Add AUTHORS file to jceks package 2016-06-03 13:24:11 -07:00
Cedric Staub 8b92817d07 Add jceks sub-package 2016-06-02 15:41:55 -07:00