Android 通过SSL/TLS使用Apache Commons上载文件的FTPS失败
我正在尝试使用ApacheCommons库在android中实现FTP文件上传。通信必须通过显式TLS身份验证完成。我可以成功登录、连接到服务器并列出文件,但当我尝试将文件存储到服务器时,它会在服务器的目标文件夹中创建一个大小为0的文件,并引发SSLexException:写入错误、管道断开。 如何克服这个问题? 下面是我的代码:Android 通过SSL/TLS使用Apache Commons上载文件的FTPS失败,android,ftps,sslexception,Android,Ftps,Sslexception,我正在尝试使用ApacheCommons库在android中实现FTP文件上传。通信必须通过显式TLS身份验证完成。我可以成功登录、连接到服务器并列出文件,但当我尝试将文件存储到服务器时,它会在服务器的目标文件夹中创建一个大小为0的文件,并引发SSLexException:写入错误、管道断开。 如何克服这个问题? 下面是我的代码: FTPSClient ftpClient = new FTPSClient("TLS", false); ftpClient.addProtocolCommandLi
FTPSClient ftpClient = new FTPSClient("TLS", false);
ftpClient.addProtocolCommandListener(new PrintCommandListener(new
KeyManagerFactory kmf = getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(null, null);
KeyManager km = kmf.getKeyManagers()[0];
ftpClient.setKeyManager(km);
ftpClient.setBufferSize(1000);
ftpClient.setConnectTimeout(5000);
ftpClient.connect(InetAddress.getByName("server ip address"), 990);
// Set protection buffer size
ftpClient.execPBSZ(0);
// // Set data channel protection to private
ftpClient.execPROT("P");
ftpClient.login("username", "password");
ftpClient.changeWorkingDirectory("/");
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
ftpClient.enterLocalPassiveMode();
buffInp = new BufferedInputStream(new FileInputStream(file.getAbsolutePath()));
//throwing exception here
boolean status = ftpClient.storeFile( picture.getName(), buffInp );
可能是服务器问题。突然开始使用相同的代码。