Skip to content

Commit

Permalink
[fix] OpenSSL::PKey::DH#set_pqg regression (#300)
Browse files Browse the repository at this point in the history
introduced at: adcd031
  • Loading branch information
kares committed May 27, 2024
1 parent d8d67cd commit 5f462bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/jopenssl/_compat23.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions src/test/ruby/test_pkey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5f462bd

Please sign in to comment.