diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java index faa917a50..718c8f611 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/JschConfigSessionFactory.java @@ -219,7 +219,13 @@ public abstract class JschConfigSessionFactory extends SshSessionFactory { private static void setPreferredKeyTypesOrder(Session session) { HostKeyRepository hkr = session.getHostKeyRepository(); - List known = Stream.of(hkr.getHostKey(hostName(session), null)) + HostKey[] hostKeys = hkr.getHostKey(hostName(session), null); + + if (hostKeys == null) { + return; + } + + List known = Stream.of(hostKeys) .map(HostKey::getType) .collect(toList());