Java 如何使用PuTTY格式的FTPSClient和密钥

Java 如何使用PuTTY格式的FTPSClient和密钥,java,putty,ftps,Java,Putty,Ftps,我需要通过FTPS(隐式或显式)连接到远程服务器。我通过FileZilla成功连接到服务器。我还测试了从公共ftp:ftp.mozilla.org检索文件的代码 现在我需要ftps的相同代码。我对私钥和密钥库有问题 String keyPath = "src/test/resources/keys/thekey.ppk"; FTPSClient client = new FTPSClient(); FileOutputStream fos = null;

我需要通过FTPS(隐式或显式)连接到远程服务器。我通过FileZilla成功连接到服务器。我还测试了从公共ftp:ftp.mozilla.org检索文件的代码 现在我需要ftps的相同代码。我对私钥和密钥库有问题

String keyPath = "src/test/resources/keys/thekey.ppk";
        FTPSClient client = new FTPSClient();
        FileOutputStream fos = null;
        try {

            KeyStore ks = KeyStore.getInstance("JKS"); //
            FileInputStream fis = new FileInputStream(keyPath);
            ks.load(fis, "".toCharArray());//java.io.IOException: Invalid keystore format
            fis.close();
            KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory
                    .getDefaultAlgorithm());
            kmf.init(ks, "".toCharArray());

            System.out.println("connecting to 1.1.1.1...");
            client.setDefaultTimeout(10000);
            client.connect("1.1.1.1", 2190);
            System.out.println("loggin in...");
            System.out.println("login: " + client.login("login", "pass"));
            String remoteDir = "/pub/downloaded/";
            String remoteFileName = "testMsg.txt";
            String localFileName = "testMsg.local.txt";

            fos = new FileOutputStream(localFileName);

            System.out.println("retrieving file...");
            boolean isRetrieved = client.retrieveFile(remoteDir + remoteFileName, fos);
            System.out.print("File: " + remoteDir + remoteFileName + "; IsRetrieved: " + isRetrieved + "\n");

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (fos != null) {
                    fos.close();
                }
                client.disconnect();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
键是以PuTTY格式生成的。我还可以在这里放置哪些选项KeyStore.getInstance(“JKS”)。 如果ommit密钥库大于代码的部分与client.retrieveFile保持一致,则该部分将挂起很长时间。
需要有关导入密钥的帮助,请参见。

FTPS表示通过SSL的FTP。SSL使用X.509证书进行身份验证(我们现在省略了其他很少使用的方法)。Putty是SSH/SFTP客户端(其中SFTP代表SSH文件传输协议),Putty密钥是SSH密钥。因此,您不能使用SSH密钥进行SSL身份验证

好的,那个么为什么当我省略keystrage的部分时,我的代码会挂起,而文件并没有出现呢?对于FileZilla,没有这样的问题。看起来没有必要使用密钥。我只是用了这个例子。那么SFTP(和SSH)呢?使用什么图书馆?