[ 
https://issues.apache.org/jira/browse/SSHD-1342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17855710#comment-17855710
 ] 

Ramanjaneyulu Mallisetty commented on SSHD-1342:
------------------------------------------------

Issue is resolved after adding following code

            List<NamedFactory<Signature>> signatureFactories = 
sshClient.getSignatureFactories();
            List<BuiltinSignatures> signatures = new ArrayList<>();
            signatures.add(BuiltinSignatures.dsa);
            signatureFactories.addAll(NamedFactory.setUpBuiltinFactories(false, 
signatures));
            sshClient.setSignatureFactories(signatureFactories);
            List<KeyExchangeFactory> keyExchangeFactories = 
sshClient.getKeyExchangeFactories();
            // Add the Diffie-Hellman-group1-sha1 key exchange factory
            keyExchangeFactories.addAll(NamedFactory.setUpTransformedFactories(
                    false,
                    Arrays.asList(BuiltinDHFactories.dhg1),
                    ClientBuilder.DH2KEX
            ));
            // Update the key exchange factories
            sshClient.setKeyExchangeFactories(keyExchangeFactories);

> Receiving error like Bad signature length (64 instead of 40)
> ------------------------------------------------------------
>
>                 Key: SSHD-1342
>                 URL: https://issues.apache.org/jira/browse/SSHD-1342
>             Project: MINA SSHD
>          Issue Type: Question
>    Affects Versions: 2.8.0
>            Reporter: Ramanjaneyulu Mallisetty
>            Priority: Major
>
> Hi, 
>         I have an application connecting to multiple SFTP servers and my 
> client code looks like below. It works for many SFTP server but getting 
> exception like below for few  servers.
>  
> WARNING: exceptionCaught(ClientSessionImpl[xxxxxxxx])[state=Opened] 
> SignatureException: Bad signature length (64 instead of 40) for 
> 56:54:55:20:42:e6:8c:7d:19:d0:01:2f:6a:10:af:1a:ed:c3:68:45:5e:0e:89:44:3f:f1:d5:55:c2:4c:ab:a7:03:1f:7f:7d:74:a1:99:75:20:4a:ff:c4:f8:a9:09:b8:cd:aa:8e:cf:b0:4a:b6:46:e7:92:61:f2:cb:ed:40:a8
> Jun 16, 2024 6:57:50 PM sftp.samples.MinaSSHClient sftp
> SEVERE: DefaultAuthFuture[ssh-connection]: Failed (SignatureException) to 
> execute: Bad signature length (64 instead of 40) for 
> 56:54:55:20:42:e6:8c:7d:19:d0:01:2f:6a:10:af:1a:ed:c3:68:45:5e:0e:89:44:3f:f1:d5:55:c2:4c:ab:a7:03:1f:7f:7d:74:a1:99:75:20:4a:ff:c4:f8:a9:09:b8:cd:aa:8e:cf:b0:4a:b6:46:e7:92:61:f2:cb:ed:40:a8
> org.apache.sshd.common.SshException: DefaultAuthFuture[ssh-connection]: 
> Failed (SignatureException) to execute: Bad signature length (64 instead of 
> 40) for 
> 56:54:55:20:42:e6:8c:7d:19:d0:01:2f:6a:10:af:1a:ed:c3:68:45:5e:0e:89:44:3f:f1:d5:55:c2:4c:ab:a7:03:1f:7f:7d:74:a1:99:75:20:4a:ff:c4:f8:a9:09:b8:cd:aa:8e:cf:b0:4a:b6:46:e7:92:61:f2:cb:ed:40:a8
>     at 
> org.apache.sshd.common.future.AbstractSshFuture.lambda$verifyResult$1(AbstractSshFuture.java:131)
>     at 
> org.apache.sshd.common.future.AbstractSshFuture.formatExceptionMessage(AbstractSshFuture.java:185)
>     at 
> org.apache.sshd.common.future.AbstractSshFuture.verifyResult(AbstractSshFuture.java:130)
>     at 
> org.apache.sshd.client.future.DefaultAuthFuture.verify(DefaultAuthFuture.java:39)
>     at 
> org.apache.sshd.client.future.DefaultAuthFuture.verify(DefaultAuthFuture.java:32)
>     at sftp.samples.MinaSSHClient.getClientSession(MinaSSHClient.java:133)
>  
>  
> Negotiated kex algorithms: diffie-hellman-group-exchange-sha256
> Negotiated host key algorithm : ssh-dss
>  
> Server proposal kex algorithms: 
> diffie-hellman-group14-sha1,diffie-hellman-group14-sha256,diffie-hellman-group-exchange-sha256
> Client proposal kex algorithms: 
> curve448-sha512,curve25519-sha...@libssh.org,curve25519-sha256,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group18-sha512,diffie-hellman-group17-sha512,diffie-hellman-group16-sha512,diffie-hellman-group15-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c
>  
>  
>     private synchronized static SshClient getSshClient() {
>         if (sshClient == null) {
>             sshClient = SshClient.setUpDefaultClient();
>             List<KeyExchangeFactory> setUpTransformedFactories = 
> NamedFactory.setUpTransformedFactories(true, BuiltinDHFactories.VALUES, 
> ClientBuilder.DH2KEX);
>             List<KeyExchangeFactory> newKexList = new ArrayList<>();
>             Collections.reverse(setUpTransformedFactories);
>             sshClient.setKeyExchangeFactories(setUpTransformedFactories); 
>             sshClient.setSignatureFactories(new 
> ArrayList<>(BuiltinSignatures.VALUES));
>             
> SftpModuleProperties.CHUNK_IF_WINDOW_LESS_THAN_PACKET.set(sshClient, true); 
>             ServerKeyVerifier serverKeyVerifier = 
> AcceptAllServerKeyVerifier.INSTANCE;
>             sshClient.setServerKeyVerifier(serverKeyVerifier);
>             sshClient.start();
>         }
>         return sshClient;
>     }
>  
> private static ClientSession getClientSession(String sftpHost, String 
> sftpPort, String sftpUser,
> String sftpPassword) throws Exception {
> SshClient client = getSshClient();
> ClientSession session = client.connect(sftpUser, sftpHost, 
> Integer.parseInt(sftpPort)).verify(10000)
> .getSession();
> session.addPasswordIdentity(sftpPassword);
> AuthFuture verify = session.auth().verify(10000);
> verify.addListener(new SshFutureListener<AuthFuture>() {
> @Override
> public void operationComplete(AuthFuture future) {
> logger.error(future.getException().getMessage(), future.getException());
>  
> }
> });
> return session;
> }



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org

Reply via email to