digitalbazaar / forge

A native implementation of TLS in Javascript and tools to write crypto-based and network-heavy webapps
https://digitalbazaar.com/
Other
5.07k stars 784 forks source link

Import private/public key from a file rather than generating one #496

Open MaxOrelus opened 7 years ago

MaxOrelus commented 7 years ago

I'm generating my keys using the following method

openssl genrsa -out rsa_1024_priv.pem 1024
openssl rsa -pubout -in rsa_1024_priv.pem -out rsa_1024_pub.pem

I'm trying to figure out how I can import my already generated key into forge and use them for encryption/decryption. I am able to read from the file and hold the key in a variable.

mattcollier commented 7 years ago

@MaxOrelus I think this post contains the information you need: https://github.com/digitalbazaar/forge/issues/87#issuecomment-28796415

mattcollier commented 7 years ago

Also, here are tests demonstrating the methods you need: https://github.com/digitalbazaar/forge/blob/94cd061f005dc2746ea9e4dddf6b23ad9c0044f9/tests/unit/rsa.js#L233