Please disregard this issue as I have gotten it to work, and if you read this 
thanks for reading.

Jon

From: Jon Madsen <jon.mad...@se.com>
Date: Tuesday, February 21, 2023 at 3:25 PM
To: users@mina.apache.org <users@mina.apache.org>
Subject: Client support for Diffie-Hellman-group1-sha1 key exchange
Hi all,

I am working on a product that needs to support legacy devices in the field 
that support the old Diffie-hellman-group1-sha1 key exchange.  I am using the 
SshClient with success with all of our other devices, however I am trying to 
figure out the proper way to add support for the dhg1 key exchange.  The 
following is a code excerpt for a my client creation, and my failed attempt to 
add the key exchange, however it does not seem to work quite right.   Any 
thoughts or help is greatly appreciated.


private SshClient createClient() {
    SshClient client = SshClient.setUpDefaultClient();

    // Get the current default list of key exchange factories
    List<KeyExchangeFactory> keyExchangeFactories = 
client.getKeyExchangeFactories();

    // Add the Diffie-Hellman-group1-sha1 key exchange factory
    keyExchangeFactories.addAll(NamedFactory.setUpTransformedFactories(
            false,
            List.of(BuiltinDHFactories.dhg1),
            ClientBuilder.DH2KEX
    ));

    // Update the factories
    client.setKeyExchangeFactories(keyExchangeFactories);

    // Dump them just to see what is set
    client.getKeyExchangeFactories().stream().forEach(kex -> 
logger.error(String.format("Client session KEX: %s", kex.getName())));
    return client;
}


Thanks,

Jon


Internal

Reply via email to