From d8fbdda2ab3fa48e92bdf37399d4b75c48409c5c Mon Sep 17 00:00:00 2001 From: ricardop Date: Wed, 3 Jan 2018 16:09:27 +0100 Subject: [PATCH] upgrade to sshd 1.6.0, add eddsa dependency, upgrade jgit to 4.1.2 --- .classpath | 9 +++--- build.moxie | 5 +-- .../transport/ssh/FileKeyPairProvider.java | 2 +- .../transport/ssh/NonForwardingFilter.java | 32 +++++++++---------- .../com/gitblit/transport/ssh/SshDaemon.java | 10 ++++-- .../gitblit/transport/ssh/WelcomeShell.java | 5 +++ .../tests/LdapPublicKeyManagerTest.java | 2 +- .../java/com/gitblit/tests/SshUnitTest.java | 2 +- 8 files changed, 39 insertions(+), 28 deletions(-) diff --git a/.classpath b/.classpath index 42cbfbc8..cfc9c939 100644 --- a/.classpath +++ b/.classpath @@ -42,7 +42,7 @@ - + @@ -50,12 +50,13 @@ - + - - + + + diff --git a/build.moxie b/build.moxie index 0b1da360..e42a41b8 100644 --- a/build.moxie +++ b/build.moxie @@ -107,12 +107,12 @@ properties: { slf4j.version : 1.7.12 wicket.version : 1.4.22 lucene.version : 5.5.2 - jgit.version : 4.1.1.201511131810-r + jgit.version : 4.1.2.201602141800-r groovy.version : 2.4.4 bouncycastle.version : 1.52 selenium.version : 2.28.0 wikitext.version : 1.4 - sshd.version: 1.2.0 + sshd.version: 1.6.0 mina.version: 2.0.16 guice.version : 4.0 # Gitblit maintains a fork of guice-servlet @@ -161,6 +161,7 @@ dependencies: - compile 'org.bouncycastle:bcprov-jdk15on:${bouncycastle.version}' :war - compile 'org.bouncycastle:bcmail-jdk15on:${bouncycastle.version}' :war - compile 'org.bouncycastle:bcpkix-jdk15on:${bouncycastle.version}' :war +- compile 'net.i2p.crypto:eddsa:0.2.0' :war !org.easymock - compile 'org.apache.sshd:sshd-core:${sshd.version}' :war !org.easymock - compile 'org.apache.mina:mina-core:${mina.version}' :war !org.easymock - compile 'rome:rome:0.9' :war :manager :api diff --git a/src/main/java/com/gitblit/transport/ssh/FileKeyPairProvider.java b/src/main/java/com/gitblit/transport/ssh/FileKeyPairProvider.java index db0741e0..cc91bb8c 100644 --- a/src/main/java/com/gitblit/transport/ssh/FileKeyPairProvider.java +++ b/src/main/java/com/gitblit/transport/ssh/FileKeyPairProvider.java @@ -26,7 +26,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; import org.apache.sshd.common.keyprovider.AbstractKeyPairProvider; -import org.apache.sshd.common.util.SecurityUtils; +import org.apache.sshd.common.util.security.SecurityUtils; import org.bouncycastle.openssl.PEMDecryptorProvider; import org.bouncycastle.openssl.PEMEncryptedKeyPair; import org.bouncycastle.openssl.PEMKeyPair; diff --git a/src/main/java/com/gitblit/transport/ssh/NonForwardingFilter.java b/src/main/java/com/gitblit/transport/ssh/NonForwardingFilter.java index f2176cb0..3164ad79 100644 --- a/src/main/java/com/gitblit/transport/ssh/NonForwardingFilter.java +++ b/src/main/java/com/gitblit/transport/ssh/NonForwardingFilter.java @@ -21,23 +21,23 @@ import org.apache.sshd.server.forward.ForwardingFilter; public class NonForwardingFilter implements ForwardingFilter { - @Override - public boolean canConnect(Type type, SshdSocketAddress address, Session session) { - return false; - } + @Override + public boolean canConnect(Type type, SshdSocketAddress address, Session session) { + return false; + } - @Override - public boolean canForwardAgent(Session session) { - return false; - } + @Override + public boolean canForwardAgent(Session session, String requestType) { + return false; + } - @Override - public boolean canForwardX11(Session session) { - return false; - } + @Override + public boolean canForwardX11(Session session, String requestType) { + return false; + } - @Override - public boolean canListen(SshdSocketAddress address, Session session) { - return false; - } + @Override + public boolean canListen(SshdSocketAddress address, Session session) { + return false; + } } diff --git a/src/main/java/com/gitblit/transport/ssh/SshDaemon.java b/src/main/java/com/gitblit/transport/ssh/SshDaemon.java index 63fa51dd..405c794e 100644 --- a/src/main/java/com/gitblit/transport/ssh/SshDaemon.java +++ b/src/main/java/com/gitblit/transport/ssh/SshDaemon.java @@ -29,7 +29,9 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.apache.sshd.common.io.IoServiceFactoryFactory; import org.apache.sshd.common.io.mina.MinaServiceFactoryFactory; import org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory; -import org.apache.sshd.common.util.SecurityUtils; +import org.apache.sshd.common.util.security.SecurityUtils; +import org.apache.sshd.common.util.security.bouncycastle.BouncyCastleSecurityProviderRegistrar; +import org.apache.sshd.common.util.security.eddsa.EdDSASecurityProviderRegistrar; import org.apache.sshd.server.SshServer; import org.apache.sshd.server.auth.pubkey.CachingPublicKeyAuthenticator; import org.bouncycastle.openssl.PEMWriter; @@ -92,9 +94,11 @@ public class SshDaemon { IStoredSettings settings = gitblit.getSettings(); // Ensure that Bouncy Castle is our JCE provider - SecurityUtils.setRegisterBouncyCastle(true); + SecurityUtils.registerSecurityProvider(new BouncyCastleSecurityProviderRegistrar()); + // Add support for ED25519_SHA512 + SecurityUtils.registerSecurityProvider(new EdDSASecurityProviderRegistrar()); if (SecurityUtils.isBouncyCastleRegistered()) { - log.debug("BouncyCastle is registered as a JCE provider"); + log.info("BouncyCastle is registered as a JCE provider"); } // Generate host RSA and DSA keypairs and create the host keypair provider diff --git a/src/main/java/com/gitblit/transport/ssh/WelcomeShell.java b/src/main/java/com/gitblit/transport/ssh/WelcomeShell.java index 7c407d36..7ea0f248 100644 --- a/src/main/java/com/gitblit/transport/ssh/WelcomeShell.java +++ b/src/main/java/com/gitblit/transport/ssh/WelcomeShell.java @@ -57,6 +57,11 @@ public class WelcomeShell implements Factory { return new SendMessage(gitblit); } + @Override + public Command get() { + return create(); + } + private static class SendMessage implements Command, SessionAware { private final IPublicKeyManager km; diff --git a/src/test/java/com/gitblit/tests/LdapPublicKeyManagerTest.java b/src/test/java/com/gitblit/tests/LdapPublicKeyManagerTest.java index c426254f..1ec6671a 100644 --- a/src/test/java/com/gitblit/tests/LdapPublicKeyManagerTest.java +++ b/src/test/java/com/gitblit/tests/LdapPublicKeyManagerTest.java @@ -28,7 +28,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.sshd.common.util.SecurityUtils; +import org.apache.sshd.common.util.security.SecurityUtils; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/com/gitblit/tests/SshUnitTest.java b/src/test/java/com/gitblit/tests/SshUnitTest.java index 1a12158a..b5b6e34b 100644 --- a/src/test/java/com/gitblit/tests/SshUnitTest.java +++ b/src/test/java/com/gitblit/tests/SshUnitTest.java @@ -26,7 +26,7 @@ import org.apache.sshd.client.future.AuthFuture; import org.apache.sshd.client.future.ConnectFuture; import org.apache.sshd.client.keyverifier.ServerKeyVerifier; import org.apache.sshd.client.session.ClientSession; -import org.apache.sshd.common.util.SecurityUtils; +import org.apache.sshd.common.util.security.SecurityUtils; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; -- 2.39.5