Skip to content

Fix OpenSSL::PKey::EC.new compatibility with openssl gem 3.0+#119

Open
yshmarov wants to merge 2 commits intorails:mainfrom
yshmarov:fix/openssl-pkey-read-compatibility
Open

Fix OpenSSL::PKey::EC.new compatibility with openssl gem 3.0+#119
yshmarov wants to merge 2 commits intorails:mainfrom
yshmarov:fix/openssl-pkey-read-compatibility

Conversation

@yshmarov
Copy link
Copy Markdown

@yshmarov yshmarov commented Mar 26, 2026

Screenshot 2026-03-26 at 11 13 12

Summary

  • OpenSSL::PKey::EC.new(pem_string) no longer accepts PEM/DER key strings since the openssl gem 3.0 (Ruby 3.2+). It now only accepts curve names (e.g., "prime256v1"), causing OpenSSL::PKey::PKeyError: invalid curve name when generating APNs JWT tokens.
  • Replace with OpenSSL::PKey.read(pem_string), which handles PEM/DER formats and is backwards-compatible with older Ruby versions.

Test plan

  • Verified push notifications deliver successfully on staging with Ruby 4.0.2 / openssl gem 4.0.1
  • Existing test suite passes (access tokens are refreshed every 30 minutes test covers the token generation flow)

Fixes #118

OpenSSL::PKey::EC.new(pem_string) no longer accepts PEM/DER key
strings since the openssl gem 3.0 (Ruby 3.2+). It now only accepts
curve names, causing `OpenSSL::PKey::PKeyError: invalid curve name`.

OpenSSL::PKey.read handles PEM/DER formats and is backwards-compatible.

Fixes rails#118
Exercises the actual OpenSSL key loading path (previously fully stubbed)
to ensure OpenSSL::PKey.read works with PEM-formatted EC keys.
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.

OpenSSL::PKey::EC.new(pem_string) broken on OpenSSL gem 3.0+ (Ruby 3.2+)

1 participant