Forum: Ruby RSA Key Question

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9117ece51252c8658aff6444fb6e6354?d=identicon&s=25 Steve Pugh (studlee2)
on 2007-04-11 17:21
(Received via mailing list)
I want to hardcode a public RSA key into a Ruby script so there is no
reliance on an external '.pem' file.  When I do that the object is of
type string and OpenSSL throws an error.

How can I get the "pub_key = OpenSSL::PKey::RSA.new(<hardcoded public
key>)" to recognize the key?

Thanks,
_Stud
15a5043475dac9278ae75efb4c71f1f6?d=identicon&s=25 Felix Windt (Guest)
on 2007-04-11 17:39
(Received via mailing list)
If it expects a file, try a StringIO object with your key:

require 'stringio'
key = StringIO.new("hardcoded key")
pub_key = OpenSSL:PKey::RSA.new(key)
This topic is locked and can not be replied to.