Hi All,
I am using SSHFTPClient and am going to switch the server validation to on. But I don't like to extend the application by public key files or known-hosts file.
What I want is to use a host public key dynamically. This extract can explain:
SSHFTPPublicKey publicKey = SSHFTPClient.getHostPublicKey(getHost());
ftp = new SSHFTPClient();
if (publicKey != null) {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
publicKey.write(outStream, SSHFTPPublicKey.OPENSSH_FORMAT);
outStream.close();
ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
ftp.getValidator().setHostValidationEnabled(true);
ftp.getValidator().addKnownHost(getHost(), inStream);
inStream.close();
}
else {
ftp.getValidator().setHostValidationEnabled(false);
}
ftp.setType(FTPTransferType.ASCII);
// set remote host
ftp.setRemoteHost(getHost());
ftp.setAuthentication(getLogin(), getPassword());
The question is if it is worth doing? I am asking because have no experiance with security. May be the SSHFTPClient is doing something the same in spite of setHostValidationEnabled(false)?
Thank you