Skip to content

Ruby 2.7 breaks OpenSSL::PKey::EC public_key to_pem #437

Description

@collimarco

In Ruby 2.6.6 (or any previous version) you can get the public key in PEM format:

curve = OpenSSL::PKey::EC.new('prime256v1')
curve.generate_key

public_key = OpenSSL::PKey::EC.new curve
public_key.private_key = nil
public_key.to_pem

When you upgrade to Ruby 2.6.7 or 2.7.0 (or any later version) the above code doesn't work anymore and changes behavior unexpectedly: it returns the private key in PEM format instead of the public key.

This breaks existing code and can potentially represent a security issue.

However the main problem is that there isn't any way to get the public key in PEM format in the new Ruby versions...

Do you have any idea how to get it? (note that curve.public_key.to_pem doesn't work either)

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