Re: [JGIT PATCH 1/2] Ignore unreadable SSH private keys when autoloading identities
- From
Shawn O. Pearce <spearce@spearce.org>
- Date
- Aug 27, 2008, 23:29 UTC
- Message-ID
- <20080827232946.GS26523@spearce.org>
- In-Reply-To
- <48B5E2A1.3030007@gmail.com>
Marek Zawirski <marek.zawirski@gmail.com> wrote:
Show 14 quoted lines
> Shawn O. Pearce wrote:
>> diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/DefaultSshSessionFactory.java b/org.spearce.jgit/src/org/spearce/jgit/transport/DefaultSshSessionFactory.java
> (...)
>> + try {
>> + addIdentity(k);
>> + } catch (JSchException e) {
>> + if (e.getMessage().startsWith("invalid privatekey: "))
>> + continue;
>> + throw e;
>> + }
>
> That's extreme error handling with JSch;) Do you really think it's
> better to rely on internal error message instead of continuing in any
> case? Which other exceptions we would like to pass level up?Oh, that's a good question. In this particular code we're just trying to prime the list of known keys so there's a chance we could later prompt you for a passphrase during the handshaking. So we probably could get away with just ignoring all JSchExceptions at this stage and treat the key as though it wasn't present...
I can't imagine what else we'd get back. A FileNotFoundException just means the user deleted the key before we could actually read it (no big deal); an IOException because the key isn't readable isn't an issue either.
I guess I can just change this to ignore everything.
-- Shawn.