Hi,
You cannot do it this way. You must store your byte array in registry and then reference it with # notation. See my answer on SO for example or this unit test.
https://stackoverflow.com/questions/57396184/apache-camel-how-to-set-a-private-key-in-a-dinamic-sftp-endpoint/57401995#57401995
https://github.com/apache/camel/blob/master/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/sftp/SftpKeyConsumeTest.java

Dne 11.8.2019 v 8:51 Nilesh Gardas napsal(a):
Hi Team,

I am looking for help in public key authentication implementation and
facing the issue while connecting to the SFTP server using private key(in
bytes).

*Issue Scenario :*

When I am passing the privatekeyFile to the endpoint url then it is working
fine but when I am trying to pass the privateKey in bytes array then
getting exception as *Invalid private key.*

*code snapshot: *

System.out.println("\n SFTP Connection Demo \n");

String
PRIVTE_KEY_PATH="C:\\Users\\hp\\Downloads\\RebexTinySftpServerBin-1.0.5\\data\\KeyPair\\private_Key01.ppk";
//uri = "sftp://[email protected]:22//BAM?privateKeyFile=
"+PRIVTE_KEY_PATH;

byte[] fileBytes = SFTPDemo.fromFile(PRIVTE_KEY_PATH);
System.out.println("\nFile bytes len : " + fileBytes.length);

uri = "sftp://Nilesh01@192.
***.**.**:22//BAM?maximumReconnectAttempts=2&privateKey="+fileBytes;

try {
DefaultCamelContext camelContext = new DefaultCamelContext();
ProducerTemplate producer = camelContext.createProducerTemplate();
Object obj=new String("123");
System.out.println(uri);
* producer.sendBodyAndHeaders(uri,obj,null);*

    } catch (CamelExecutionException e) {
        System.out.println("\nException Nilesh :"+ e +"\n" +
e.getCause().getCause());

    }catch(Exception e) {
     System.out.println("\nException Nilesh :"+ e);
    }

Thank you for your help in advance...!!!

Could you please assist me how to pass privateKey parameter in the endpoint
uri.


Reply via email to