diff --git a/lib/jopenssl/_compat23.rb b/lib/jopenssl/_compat23.rb index 8da642c6..78f9d0ef 100644 --- a/lib/jopenssl/_compat23.rb +++ b/lib/jopenssl/_compat23.rb @@ -14,9 +14,9 @@ def set_key(pub_key, priv_key) def set_pqg(p, q, g) self.p = p - if respond_to?(:q) + if respond_to?(:q=) self.q = q - else # TODO self.q = q + else OpenSSL.warn "JRuby-OpenSSL does not support setting q param on #{inspect}" if q end self.g = g diff --git a/src/test/ruby/test_pkey.rb b/src/test/ruby/test_pkey.rb index 30b83489..2a0f0e12 100644 --- a/src/test/ruby/test_pkey.rb +++ b/src/test/ruby/test_pkey.rb @@ -83,6 +83,20 @@ def test_pkey_pem_file_error end end + def test_pkey_dh + dh = OpenSSL::PKey::DH.new + assert_equal nil, dh.p + assert_equal nil, dh.priv_key + + # OpenSSL::PKey::PKeyError: dh#set_pqg= is incompatible with OpenSSL 3.0 + if defined? JRUBY_VERSION + dh.set_pqg(1_000_000, nil, 10) + assert_equal 1_000_000, dh.p + assert_equal 10, dh.g + end + assert_equal nil, dh.q + end + def test_to_java pkey = OpenSSL::PKey.read(KEY) assert_kind_of java.security.PublicKey, pkey.to_java