-
Notifications
You must be signed in to change notification settings - Fork 56
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
Allow using password-protected private keys #797
base: develop
Are you sure you want to change the base?
Conversation
c98f607
to
c572489
Compare
Hello @fghanmi! Thank you for this. I'll share this with the rest of the team, but while we take a look at it would you be able to do a |
tough/Cargo.toml
Outdated
@@ -35,6 +35,7 @@ typed-path = "0.9" | |||
untrusted = "0.9" | |||
url = "2" | |||
walkdir = "2" | |||
openssl = "0.10" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we have in the near past worked to remove openssl from the dependencies of tough and would prefer to keep it that way. Is there a way to adjust this implementation to rely on rustls instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that reading password encrypted private keys is not yet supported by rustls(pemfile) as per this issue. They've suggested to use pkcs8 instead.
So, I've done the same and removed openssl.
Hello @jpculp, |
I was able to run |
@jpculp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the formatting fix! We are still evaluating this, but I left a couple of small changes in the code in the meantime.
Hello @jpculp , |
@fghanmi, apologies for the delays. It's still under review, but the gears are in motion. Something that might help is if you are able to include a small unit test for handling a password protected key. The same is true for adding a small test for SHA512 hashes in #814. Thank you for your patience in all of this. |
Thank you for the quick follow-up! It looks like if we bump let encrypted_private_key_document = pkcs8::EncryptedPrivateKeyInfo::from_der(pem.contents())?;
let decrypted_private_key_document =
encrypted_private_key_document.decrypt(password.as_bytes())?;
let decrypted_key_bytes: Vec<u8> = decrypted_private_key_document.as_bytes().to_vec(); |
I think we're getting close here. @fghanmi, would you be able to include example output in the description if the password is incorrect? |
@jpculp , I hope I understood you correctly, I've added an error example to the PR description. |
Signed-off-by: Firas Ghanmi <[email protected]>
Signed-off-by: Firas Ghanmi <[email protected]>
Signed-off-by: Firas Ghanmi <[email protected]>
Signed-off-by: Firas Ghanmi <[email protected]>
Signed-off-by: Firas Ghanmi <[email protected]>
Signed-off-by: Firas Ghanmi <[email protected]>
Signed-off-by: Firas Ghanmi <[email protected]>
Signed-off-by: Firas Ghanmi <[email protected]>
Signed-off-by: Firas Ghanmi <[email protected]>
Signed-off-by: Firas Ghanmi <[email protected]>
Signed-off-by: Firas Ghanmi <[email protected]>
I'm not a maintainer, so I'll leave this as a drive by comment, not a review: In my opinion "--password" is an anti pattern in any cli: It practically guarantees users are going to make a mistake and the password is then available in shell history and /proc/. |
Issue #, if available:
#796
Description of changes:
If the password is invalid, the code will throw the following error:
Failed to sign repository: Unable to parse keypair: Unrecognized private key format
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.