Refactor key loading logic into its own method for clarity and better er...#224
Closed
alanfranz wants to merge 1 commit intoparamiko:masterfrom
Closed
Refactor key loading logic into its own method for clarity and better er...#224alanfranz wants to merge 1 commit intoparamiko:masterfrom
alanfranz wants to merge 1 commit intoparamiko:masterfrom
Conversation
… error reporting.
Member
|
Subsumed by #387. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Many a time, when trying to login to a server using multiple RSA keys through the key_filename parameter, I got an error like "Not a valid DSA key file". This was puzzling because all keys were in fact RSA, and perfecly valid, and I was able to log in other servers.
In fact the issue was different: the problem lied in the fact that the public key matching the private RSA key was not in the target authorized_keys file, but the connection logic "masked" the true error with the last "saved exception", and since it tried to load DSA keys after RSA keys, the error was always "not a valid DSA key file".
This proposal splits the key loading part into its own method, with its own exception; in this situation, the correct "authentication failed" exception will be propagated. Of course, if an invalid RSA/DSA key file is found after an authentication failure, it's still the latter error that will be propagated, yet I think it's an improvement over the original behaviour.