Browse Source

Automatically reload known_hosts file

JGit caches the contents of the known_hosts file within JSch when
first started, and never attempts to re-read it.  If the contents
change (such as when using Gerrit replication), the new host will
never be found.

On failures, try reloading the knonwn_hosts and retry the
connection, in addition to reloading the credentials.

Change-Id: I980c4f4003f2a48c71b9b47c51e640d1e7742f58
Signed-off-by: Doug Kelly <dougk.ff7@gmail.com>
stable-3.4
Doug Kelly 11 years ago
parent
commit
44025d4c54
  1. 3
      org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java

3
org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java

@ -117,6 +117,9 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory {
} catch (JSchException e) { } catch (JSchException e) {
session.disconnect(); session.disconnect();
session = null; session = null;
// Make sure our known_hosts is not outdated
knownHosts(getJSch(hc, fs), fs);
// if authentication failed maybe credentials changed at the // if authentication failed maybe credentials changed at the
// remote end therefore reset credentials and retry // remote end therefore reset credentials and retry
if (credentialsProvider != null && e.getCause() == null if (credentialsProvider != null && e.getCause() == null

Loading…
Cancel
Save