fukamachi / pem

PEM parser.
14 stars 3 forks source link

`read-from-file` fails on openssl generated private key. #6

Closed mooseyboots closed 10 months ago

mooseyboots commented 10 months ago

if i run openssl genrsa -out private.pem 2048 to make a RSA key saved to private.pem, i'm unable to read it with pem:read-from-file.

firstly, the file's header is "BEGIN PRIVATE KEY", not "BEGIN RSA PRIVATE KEY", so the assoc call fails.

but even if i add RSA to the pem file, or remove the RSA from the assoc string that does the check, read-private-key still fails and i get the Unexpected format error.

do you have any ideas about how to get this working? or how to create a private key pem file in a way that this library will happily read it?

(apologies if this is glaringly obvious, i'm no crypto expert.)

mooseyboots commented 10 months ago

it worked for me using the -traditional flag in openssl:

openssl genrsa -traditional -out outfile.pem 2048