Skip to content

[fix] read back DER written by PKey#to_der (backport to 0.16) - #397

Open
matrei wants to merge 1 commit into
jruby:0.16from
matrei:fix/pkey-read-der-0.16
Open

matrei wants to merge 1 commit into
jruby:0.16from
matrei:fix/pkey-read-der-0.16

Conversation

@matrei

@matrei matrei commented Nov 2, 2026

Copy link
Copy Markdown

Backport of b07bf83 to 0.16, which JRuby 10.0 and 9.4 bundle. On 0.16.3, OpenSSL::PKey.read can't read the DER that #to_der writes for RSA, DSA and EC private keys:

OpenSSL::PKey.read(OpenSSL::PKey::RSA.new(2048).to_der)
# OpenSSL::PKey::PKeyError: Could not parse PKey: unsupported

Two changes from the original: the new catch block calls debugStackTrace like its neighbours, since 0.16 has no LOG, and the test moved to src/test/ruby/test_pkey.rb.

With JRuby 10.0 on JDK 21, ./mvnw test passes as on 0.16, and rake test runs 522 tests with no failures, one more than on 0.16. The new test fails without the fix.

PKey.read only tried PKCS#8 on DER input

(cherry picked from commit b07bf83)
[backport: debugStackTrace instead of LOG.debugStack, which 0.16 doesn't have; test moved to src/test/ruby]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants