ruby / ruby/openssl

OpenSSL::PKey::RSA.generate always returns a OpenSSL::PKey::RSA, even when sublcassed, on Ruby 3.1/openssl-3.0.0

Open
#512 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
276
Forks
200
Avg merge
1d 19h
Merged PRs (30d)
7

Description

I noticed a change in behavior for OpenSSL::PKey::RSA.generate between Ruby 3.0 (openssl-2.x) and ruby 3.1 (openssl-3.0.0). In Ruby 3.1 OpenSSL::PKey::RSA.generate will always return a OpenSSL::PKey::RSA instance, even when the class has been sublcassed.

Steps To Reproduce

require 'openssl'

class MyRSA < OpenSSL::PKey::RSA
end

p MyRSA.generate(1024)

Expected Behavior

#<MyRSA:...>

Actual Behavior

#<OpenSSL::PKey::RSA:...>

Version

  • Ruby 3.0 (Works):
    • ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-linux]
    • `openssl (default: 2.2.1)
  • Ruby 3.1 (Fails):
    • ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
    • openssl (default: 3.0.0)

This regression seems to have appeared in 3.0.0.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the OpenSSL::PKey::RSA.generate entry point and the MyRSA subclass shown in the report. Trace how generate constructs its return value in the Ruby OpenSSL extension, then add coverage confirming the subclass is preserved and run the relevant OpenSSL tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cryptography
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.