Bug #7074

OpenSSL::PKey::RSA.new(public_key) fails if public_key doesn't have -----BEGIN PUBLIC KEY-----

Added by David Lee over 1 year ago. Updated over 1 year ago.

[ruby-core:47705]
Status:Rejected
Priority:Normal
Assignee:Martin Bosslet
Category:ext
Target version:1.9.3
ruby -v:ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.0.0] Backport:

Description

=begin

public_key1 = <<KEY
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCfW7fNVCLBii/Ky/H97w9BAL6H
ifRM9sJkxo1dqCzvYHLk/89OmYMoDJ2+OgHRaoRpP+CSHiTkxQR1G+UbHLiQpZMo
CbcHAN6nDVET5ulgA8xywOAuIEgsJ5CmhWG79rZGqDNg6N2V5jgZ8WgLRuTn6aGb
+HqF23BDbpOUX8pGcQIDAQAB
-----END PUBLIC KEY-----
KEY

public_key2 = <<KEY
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCfW7fNVCLBii/Ky/H97w9BAL6H
ifRM9sJkxo1dqCzvYHLk/89OmYMoDJ2+OgHRaoRpP+CSHiTkxQR1G+UbHLiQpZMo
CbcHAN6nDVET5ulgA8xywOAuIEgsJ5CmhWG79rZGqDNg6N2V5jgZ8WgLRuTn6aGb
+HqF23BDbpOUX8pGcQIDAQAB
KEY

OpenSSL::PKey::RSA.new publickey1 #=> works
OpenSSL::PKey::RSA.new public
key2 #=> fails with error:
# OpenSSL::PKey::RSAError: Neither PUB key nor PRIV key:: nested asn1 error

=end

History

#1 Updated by Martin Bosslet over 1 year ago

  • Category set to ext
  • Status changed from Open to Rejected
  • Assignee set to Martin Bosslet

publickey2 is not a valid PEM format (the one in publickey1). It's valid Base64, true, but that's not what OpenSSL expects. It can deal with either DER- or PEM-encoded data. In my eyes, there's nothing wrong here, or did you mean something else? Unless you object, I would close this as "Rejected" to indicate that the behavior is intended and not a bug.

PS: A clean way to deal with raw Base64 data such as in public_key2 would be to Base64-decode it first and then passing it on as in your example.

Also available in: Atom PDF