From: armourcomms1337@... Date: 2016-05-06T16:11:00+00:00 Subject: [ruby-core:75387] [Ruby trunk Bug#12354] PKey::EC Can't output public key pem when private key exists Issue #12354 has been reported by Armour Comms. ---------------------------------------- Bug #12354: PKey::EC Can't output public key pem when private key exists https://bugs.ruby-lang.org/issues/12354 * Author: Armour Comms * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- Steps to reproduce: Create EC key: key = OpenSSL::PKey::EC.new("prime256v1") key.generate_key Try and output in pem format key.to_pem #Outputs private key pem key.public_key.to_pem #Error In order to output a public key pem, a new key object must be created with no private key: key_pub = OpenSSL::PKey::EC.new(key.group) key_pub.public_key = key.public_key Output pem key_pub.to_pem #Success! From viewing the source, http://rxr.whitequark.org/mri/source/ext/openssl/ossl_pkey_ec.c#466 it seems that if the key is private there is no way to output a public key for that key object -- https://bugs.ruby-lang.org/ Unsubscribe: