Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save the privatekey #31

Closed
readlnh opened this issue Nov 26, 2019 · 5 comments
Closed

save the privatekey #31

readlnh opened this issue Nov 26, 2019 · 5 comments

Comments

@readlnh
Copy link

readlnh commented Nov 26, 2019

Is there a feature that can save/export private key easily?

@penumbra23
Copy link

It's merged in #38
Waiting for new crate release

@jeffrade
Copy link

@penumbra23 It looks like #38 only provides one direction (parse/from/import from a public or private key file). What I think would be nice is to be able to have functions like to_pkcs[1|8] and try_to().

For example, given an RSAPublicKey, be able to output:

-----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAK5Z7jk1ql5DquRvlPmFgyBDCvdPQ0T2
si2oPAUmNw2Z/qb2Sr/BEBoWpagFf8Gl1K4PRipJSudDl6N/Vdb2CYkCAwEAAQ==
-----END PUBLIC KEY-----

so that it (and an RSAPrivateKey) can be saved to disk.

@penumbra23
Copy link

Yup sorry, my bad. Thought that this would go in the same feature (which seems to be logical). But for any purpose you can generate the keys somewhere offline, save it and import.

@jeffrade
Copy link

But for any purpose you can generate the keys somewhere offline, save it and import.

My use case is I generate the keys in my app using this lib like so:

let private_key = RSAPrivateKey::new(&mut rng, bits).expect("failed to generate a key");
let public_key: RSAPublicKey = private_key.into();

then I would like to persist to disk so that next time the app starts up, I can check if keys exist and use them (instead of generating a new set). Instead of using a built in Rust serializer, I would prefer to write out in ASN.1 notation.

@dignifiedquire
Copy link
Member

We have full pkcs1 & pcks8 support now, so closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants