camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joerg Kessler (JIRA)" <>
Subject [jira] [Created] (CAMEL-6514) SFTP: NPE if no private key file is supplied
Date Fri, 05 Jul 2013 14:11:48 GMT
Joerg Kessler created CAMEL-6514:

             Summary: SFTP: NPE if no private key file is supplied
                 Key: CAMEL-6514
             Project: Camel
          Issue Type: Bug
          Components: camel-ftp
    Affects Versions: 2.10.4
            Reporter: Joerg Kessler
            Priority: Minor

a NPE is thrown if no private key file is supplied in the configuration for SFTP. The error
Caused by: java.lang.NullPointerException: while trying to get the length of an array loaded
from local variable 'foo'
at com.jcraft.jsch.Buffer.putString(
I have analysed the code a bit and found that the problem is caused
by the class SftpOperations. The method createSession sets the userInfo for the seesion by
an inline class. Here the method promptKeyboardInteractive does not work correctly if no private
key file is supplied. In that case JSCH switches to user/pw authorization and this method
is called. But since there is no password maintained the configation object returns NULL.
The present implementation adds it to the string array causing the error in JSCH. JSCH either
wants a NULL string array or an empty string array (I have tested both). So the code should
look e.g. as follows:

            public String[] promptKeyboardInteractive(String destination, String name, String
instruction, String[] prompt, boolean[] echo) {
                String password = configuration.getPassword();
                if (password == null) {
                    return new String[0];
                } else {
                    return new String[] { password };
With that change JSCH returns
Caused by: ./data/ssh/id_rsa (No such file or directory)
	at Method)

and that is the real cause of the error 

Best Regards,


This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message