Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenSSL::PKey.read fails for valid pkey #299

Open
segiddins opened this issue Apr 30, 2024 · 0 comments
Open

OpenSSL::PKey.read fails for valid pkey #299

segiddins opened this issue Apr 30, 2024 · 0 comments

Comments

@segiddins
Copy link

#!/usr/bin/env ruby

require 'rubygems'
require 'openssl'

puts OpenSSL::OPENSSL_VERSION

b64 = "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEbfwR+RJudXscgRBRpKX1XFDy3PyudDxz/SfnRi1fT8ekpfBd2O1uoz7jr3Z8nKzxA69EUQ+eFCFI3zeubPWU7w=="
key = OpenSSL::PKey.read(b64.unpack1("m"))

puts key.to_text

pp OpenSSL::Digest::SHA256.hexdigest(key.public_to_der)

on mri:

OpenSSL 3.3.0 9 Apr 2024
Public-Key: (256 bit)
pub:
    04:6d:fc:11:f9:12:6e:75:7b:1c:81:10:51:a4:a5:
    f5:5c:50:f2:dc:fc:ae:74:3c:73:fd:27:e7:46:2d:
    5f:4f:c7:a4:a5:f0:5d:d8:ed:6e:a3:3e:e3:af:76:
    7c:9c:ac:f1:03:af:44:51:0f:9e:14:21:48:df:37:
    ae:6c:f5:94:ef
ASN1 OID: prime256v1
NIST CURVE: P-256
"086092f02852ff6845d1d16b27849c456718ac163dc338d26de6bc2206366f72"

on jruby:

JRuby-OpenSSL 0.14.5
OpenSSL::PKey::PKeyError: Could not parse PKey: unsupported
  <main> at Untitled 2.rb:9
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

No branches or pull requests

1 participant