diff options
author | Florian Zschocke <f.zschocke+git@gmail.com> | 2022-10-25 00:00:03 +0200 |
---|---|---|
committer | Florian Zschocke <f.zschocke+git@gmail.com> | 2022-10-25 00:01:01 +0200 |
commit | 27b51f69b7c336c082f80896ee580bd836350960 (patch) | |
tree | 078a76cbdab5cb4977021c8746d9a40f164ecbe6 | |
parent | 366a14f278095bb28956298bd8c3c64b247700cb (diff) | |
download | gitblit-27b51f69b7c336c082f80896ee580bd836350960.tar.gz gitblit-27b51f69b7c336c082f80896ee580bd836350960.zip |
Skip SSH host key files that do not exist
Since we now do not generate a DSA host key file anymore, but keep it in
the list of potential keys so that existing keys still work, it can
happen that the files for DSA (and Ed25519) are getting loaded but they
do not exist. This results in an error in the log.
So instead check if the file exists and only try to load files that
exist. This prevents from errors (which are none) being spammed in the
log.
-rw-r--r-- | src/main/java/com/gitblit/transport/ssh/FileKeyPairProvider.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main/java/com/gitblit/transport/ssh/FileKeyPairProvider.java b/src/main/java/com/gitblit/transport/ssh/FileKeyPairProvider.java index aaa606ce..0e97f557 100644 --- a/src/main/java/com/gitblit/transport/ssh/FileKeyPairProvider.java +++ b/src/main/java/com/gitblit/transport/ssh/FileKeyPairProvider.java @@ -18,6 +18,7 @@ */ package com.gitblit.transport.ssh; +import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.security.KeyFactory; @@ -122,6 +123,11 @@ public class FileKeyPairProvider extends AbstractKeyPairProvider { while (iterator.hasNext()) { String file = iterator.next(); + File f = new File(file); + if (!f.isFile()) { + log.debug("File does not exist, skipping {}", file); + continue; + } nextKeyPair = doLoadKey(file); if (nextKeyPair != null) { nextKeyPairSet = true; |