Skip to content

Add missing OpenSSL::SSL::SSLContext and SSLSocket methods - #3301

Open
hasannadeem wants to merge 1 commit into
ruby:masterfrom
hasannadeem:openssl-ssl-methods
Open

hasannadeem wants to merge 1 commit into
ruby:masterfrom
hasannadeem:openssl-ssl-methods

Conversation

@hasannadeem

Copy link
Copy Markdown
Contributor

These OpenSSL::SSL methods had no signatures:

Method Signature Since
SSLContext#ciphersuites= (String | Array[String]) -> (String | Array[String]) openssl 3.x
SSLContext#tmp_dh= (PKey::DH) -> PKey::DH 3.x
SSLContext#keylog_cb, #keylog_cb= (^(SSLSocket ssl, String line) -> void)? 3.x
SSLContext#groups= (String) -> String 4.0
SSLContext#sigalgs=, #client_sigalgs= (String) -> String 4.0
SSLSocket#close_read, #close_write () -> nil 3.x
SSLSocket#export_keying_material (String label, int length, ?String? context) -> String 3.x
SSLSocket#group, #sigalg, #peer_sigalg () -> String? 4.0

Notes:

  • keylog_cb follows the getter/setter pairs used for the other callbacks (servername_cb, renegotiation_cb). The setter also accepts nil, which clears the callback.
  • tmp_dh= rejects other key types at runtime (invalid pkey type ... (expected DH)), so it takes PKey::DH.
  • ecdh_curves= is now a deprecated alias of groups=, but this leaves its existing signature alone.

There were no SSLSocket instance tests, so OpenSSLSSLFixtures.connected makes a real TLS connection over loopback TCP with a self-signed EC certificate. The tests check:

  • the values after a handshake: the client's group and peer_sigalg are Strings, and its sigalg is nil since only the server signs;
  • tmp_dh=, using OpenSSL::PKey.generate_parameters("DH", "group" => "ffdhe2048") so no DH parameters have to be generated.

All 12 new tests fail without the signature change. They pass with openssl 4.0.2 (Ruby 4.0.7), three runs in a row, and with openssl 3.3.0 (Ruby 3.4), where the six openssl 4.0 tests are omitted. With Steep, the setters, export_keying_material, group&.upcase and a lambda keylog_cb pass, and tmp_dh = <EC key> is an error. Annotating core and stdlib from the full v4.0.7 source leaves the file unchanged, and rake validate and rake typecheck_test pass.

Calling SSLSocket#group before the handshake segfaults with OpenSSL 3.6.3. That is an OpenSSL bug (openssl/openssl#32379, fixed by openssl/openssl#32452), so the test calls it only after the handshake.

This PR merges with #3291, #3299 and #3300 without conflicts.

SSLContext#ciphersuites=, #tmp_dh=, #keylog_cb and #keylog_cb= (openssl 3.x),
#groups=, #sigalgs= and #client_sigalgs= (openssl 4.0), and SSLSocket#close_read,
#close_write, #export_keying_material (openssl 3.x), #group, #sigalg and
#peer_sigalg (openssl 4.0) had no signatures.
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.

1 participant