DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • The Quantum Computing Mirage: What Three Years of Broken Promises Have Taught Me
  • Discover Hidden Patterns with Intelligent K-Means Clustering
  • Mastering Approximate Top K: Choosing Optimal Count-Min Sketch Parameters
  • The Real-time Data Transfer Magic of Doris Kafka Connector's "Data Package": Part 1

Trending

  • Ujorm3: A New Lightweight ORM for JavaBeans and Records
  • Slopsquatting: Building a Scanner That Catches AI-Hallucinated Packages Before They Reach Production
  • Ingesting Fixed-Width Mainframe Files Into Delta Lake: The Details Nobody Writes Down
  • When Perfect Data Breaks: The Journey from Data Quality to Data Observability
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. How to Solve Mule SFTP Connector Algorithm Negotiation Fail Exception

How to Solve Mule SFTP Connector Algorithm Negotiation Fail Exception

This quick tutorial will show you how to resolve issues with the Mule SFTP connector connecting to remote file locations.

By 
Rajiv Mishra user avatar
Rajiv Mishra
·
Dec. 29, 17 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
24.7K Views

Join the DZone community and get the full member experience.

Join For Free

This article is the resolution of the Mule SFTP connector when connecting to remote file locations.

The configurations details are below:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
       xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd">
       <sftp:connector name="SFTP" validateConnections="true" doc:name="SFTP" />
       <flow name="sftpflow">
             <sftp:inbound-endpoint connector-ref="SFTP" host="host_ip" port="22" path="File Loactions " user="USERNAME" password="PASSWORD"
                    responseTimeout="10000" doc:name="SFTP" >
            <reconnect count="3"/>
        </sftp:inbound-endpoint>
             <logger message="Able to read file :- #[payload]" level="INFO" doc:name="Logger" />
       </flow>
</mule>


The exception will be:

com.jcraft.jsch.JSchException: Algorithm negotiation fail
       at com.jcraft.jsch.Session.receive_kexinit(Session.java:583) ~[jsch-0.1.51.jar:?]


The SFTP connector for Mule has the in-built support jsch-0.1.51.jar. So, while connecting to secure file locations through the SFTP connector, the com.jcraft.jsch.JSchException: Algorithm negotiation fail exception is thrown.

In the JSch.class for jsch-0.1.51.jar, for the KEY -->"kex," it does not have the value "diffie-hellman-group-exchange-sha256" for connecting to the remote location securely. The sha256 exchange pattern is required, which is there in the jsch-0.1.54.jar file. But for 3.6.2/3.7.1 and 3.8.1 runtime versions, the in-built third party jsch-0.1.51.jar has been used.

The Workaround

 Override the KEY "kex" and add the value diffie-hellman-group-exchange-sha256.

The following block should be added in the Static block:

configuration.put("kex", "diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256");

JSch.setConfig(configuration);

public class JSchKeyConfig {
 static {
  Properties configuration = new Properties();
  configuration.put("kex", "diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256");
  JSch.setConfig(configuration);
 }


Inject the JSchKeyConfig through Spring beans. 

Connector (mathematics) Algorithm

Opinions expressed by DZone contributors are their own.

Related

  • The Quantum Computing Mirage: What Three Years of Broken Promises Have Taught Me
  • Discover Hidden Patterns with Intelligent K-Means Clustering
  • Mastering Approximate Top K: Choosing Optimal Count-Min Sketch Parameters
  • The Real-time Data Transfer Magic of Doris Kafka Connector's "Data Package": Part 1

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook