Skip to content

docs: Replace deprecated methods/classes in examples - #1117

Merged
rhenium merged 2 commits into
ruby:masterfrom
junaruga:wip/doc-replace-deprecated-class-method-examples
Oct 2, 2026
Merged

rhenium merged 2 commits into
ruby:masterfrom
junaruga:wip/doc-replace-deprecated-class-method-examples

Conversation

@junaruga

@junaruga junaruga commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

This PR fixes the document issues that deprecated SSLContext#cert=/key= and SSLServer are used in the code examples. It has the following 2 commits. See the commit messages for details. I confirmed the rdoc files generated by bundle exec rake rdoc.

  • docs: Replace deprecated SSLContext#cert=/key= with add_certificate in example
  • docs: Replace deprecated SSLServer references with SSLSocket

…n example

The SSLContext#cert= and #key= methods are deprecated in favor
of #add_certificate. Update the SSL server example in ossl.c.

Assisted-by: Claude:Opus 4.6
@junaruga junaruga changed the title docs: Replace deprecated mthods/classes in examples docs: Replace deprecated methods/classes in examples Oct 2, 2026
The commit a77ed4b deprecated SSLServer.
Update code examples and the OpenSSL::SSL module description
to use SSLSocket and TCPServer instead.

Fix OpenSSL::DH.generate to OpenSSL::PKey::DH.generate in the
tmp_dh= example.

Remove P-224 from #groups= example, as I got an error with P-224
on my local OpenSSL 4.1.0-dev.

test.rb
```
require 'openssl'
require 'socket'

tcp_svr = TCPServer.new('127.0.0.1', 10043)
ctx1 = OpenSSL::SSL::SSLContext.new
ctx1.groups = "X25519:P-256:P-224"
Thread.new {
  ssl = OpenSSL::SSL::SSLSocket.new(tcp_svr.accept, ctx1)
  ssl.accept
}
```

```
$ ruby -I lib -r openssl -e 'puts OpenSSL::OPENSSL_VERSION'
OpenSSL 4.1.0-dev

$ ruby -I ./lib test.rb
...
test.rb:9:in 'OpenSSL::SSL::SSLSocket#accept': SSL_accept returned=1 errno=0 peeraddr=127.0.0.1:54616 state=error: no shared cipher (OpenSSL::SSL::SSLError)
OpenSSL error queue reported 1 errors:
error:0A0000C1:SSL routines:tls_post_process_client_hello:no shared cipher
	from test.rb:9:in 'block in <main>'
test.rb:16:in 'OpenSSL::SSL::SSLSocket#connect': SSL_connect returned=1 errno=0 peeraddr=127.0.0.1:10043 state=error: tls alert handshake failure (SSL alert number 40) (OpenSSL::SSL::SSLError)
OpenSSL error queue reported 1 errors:
error:0A000410:SSL routines:ssl3_read_bytes:tls alert handshake failure (SSL alert number 40)
	from test.rb:16:in '<main>'
```

Assisted-by: Claude:Opus 4.6
@junaruga
junaruga force-pushed the wip/doc-replace-deprecated-class-method-examples branch from 55b22d3 to ed62ad4 Compare October 2, 2026 17:37
@rhenium
rhenium merged commit e3cc410 into ruby:master Oct 2, 2026
48 checks passed
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