Skip to content

OpenSSL::PKey.generate_key added in 0.16.1 breaks net-ssh DH key exchange (TypeError: DH is not a string) #366

Description

@tkaabbc

Summary

Hi team, in jruby-openssl 0.16.1, OpenSSL::PKey.respond_to?(:generate_key) returns true,
but OpenSSL::PKey.generate_key only accepts a String algorithm name (EdDSA).
net-ssh calls:

OpenSSL::PKey.generate_key(dh_params)  # dh_params is OpenSSL::PKey::DH

This raises: TypeError: #<OpenSSL::PKey::DH:...> is not a string

In 0.15.3, generate_key did not exist on OpenSSL::PKey, so net-ssh used: dh_params.generate_key! instead, which worked.

Impact

Breaks net-ssh / net-sftp SSH handshake on JRuby after upgrading to 0.16.1 (Diffie-Hellman kex path).

Reproduction

# jruby-openssl 0.16.1
require "openssl"
p OpenSSL::PKey.respond_to?(:generate_key)  # => true
OpenSSL::PKey.generate_key(OpenSSL::PKey::DH.new)
# => TypeError: #<OpenSSL::PKey::DH:...> is not a string

Also reproducible via any Net::SFTP.start / Net::SSH.start using classic DH kex.

Environment

jruby-openssl 0.16.1-java
net-ssh 7.2.3
JRuby 9.4.9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions