--mimepart_4d630149eb640_1dc2acf477a33486
Content-Type: text/plain
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline

Feature #4424: [ext/openssl] Allow public/private key creation from arbitrary data
http://redmine.ruby-lang.org/issues/show/4424

Author: Martin Bosslet
Status: Open, Priority: Normal
Category: ext, Target version: 1.9.3

There is a public funtion in PKey that allowed to read arbitrary
private keys from a file regardless of the actual key type, but it
was not exposed in Ruby, only in C. n Ruby, the only way to instantiate public/private keys is by alling initialize on the correct PKey subclass, implying that ou need to know what kind of key you're actually dealing with. here are situations where the key type is not known in advance, .g. if a certificate SubjectPublicKeyInfo shall be turned into ublic key. In that case you only know that you're dealing with
a public key, but not necessarily with what kind of key. In ituations like these it would come in handy to have methods that
create a PKey instance regardless of the underlying data.

The attached patch provides this by adding two module functions to Key, read_public and read_private. They allow reading generic ublic/private keys from a String or a File, optionally providing
a password in the case of encrypted PEM encodings. RDoc has also
been supplemented.

Please note that the included tests partly rely on the patches roposed in

http://redmine.ruby-lang.org/issues/show/4421,
http://redmine.ruby-lang.org/issues/show/4422 and
http://redmine.ruby-lang.org/issues/show/4423

If those were applied, the combination with this patch would rovide consistent behavior among all three public key systems
supported in Ruby.

Regards,
Martin


----------------------------------------
http://redmine.ruby-lang.org

--mimepart_4d630149eb640_1dc2acf477a33486
Content-Type: application/x-gzip; name=pkey_from_data.tar.gz
Content-Transfer-Encoding: Base64
Content-Disposition: attachment; filename=pkey_from_data.tar.gz

H4sIALfmYk0AA+1YbW/aSBDO1/hXbDldYzAQsCG09HpNmtIqaq7lQlLpdDpZ
xl4nboztrk3SXJX/frO7fiMEYyhNVN0+EhizO++zM2MHl/hGt4k/0S0jMpqW
Y9tbm0YLsNfp0Gu7123lr/RnW223ttrtrtbq7mlqW9tqtTuq1tlCrY1rcg+m
YWQQhLYmBokcb/G+Zes/KY48C3/tIzId3+zir9GuH2AvDN1dH770AJKjaUov
vx9So9EoFLItE3zlhI7vIa31XHtWlRRFWUJx7ZNLxztHph/cVKX9f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