ruby-jose icon indicating copy to clipboard operation
ruby-jose copied to clipboard

OpenSSL::PKey::PKeyError when JOSE::JWK.generate_key([:rsa, 1024])

Open TC-SJ-Yoon opened this issue 1 year ago • 1 comments

Hello,

I've updated Ruby version from 3.0.2 to 3.2.2 on my Mac (Intel chip) with this

brew install [email protected]
ruby-install ruby-3.2.2 -- --with-openssl-dir=$(brew --prefix [email protected])
chruby 3.2.2

In the gem file I have...

gem 'jose'
gem 'jwt'

When I generate key like this..

jwk = JOSE::JWK.generate_key([:rsa, 1024])

I receive the error

Minitest::UnexpectedError: OpenSSL::PKey::PKeyError: EVP_PKEY_CTX_ctrl_str(ctx, "rsa_keygen_pubexp", "")

I'm not sure how to debug the issue. Could someone help me to figure out the issue?

TC-SJ-Yoon avatar Aug 15 '23 17:08 TC-SJ-Yoon

It seems that this is being triggered when generating any key using the gem.

I'm using a MacOS X with:

$ openssl version
OpenSSL 3.1.3 19 Sep 2023 (Library: OpenSSL 3.1.3 19 Sep 2023)

I tried:

JOSE::JWE.generate_key({"alg" => "RSA-OAEP-256", "enc" => "A256GCM"})
JOSE::JWE.generate_key({"alg" => "RSA-OAEP-256", "enc" => "A128GCM"})
JOSE::JWK.generate_key([:rsa, 2048])
JOSE::JWS.generate_key({"alg" => "RS256"})

All are throwing the same error.

When I try:

OpenSSL::PKey::EC.generate('prime256v1')

It works.

andrer0cha avatar Oct 31 '23 14:10 andrer0cha