Skip to content

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

Open
@segiddins

Description

@segiddins
#!/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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      OpenSSL::PKey.read fails for valid pkey · Issue #299 · jruby/jruby-openssl