[英]How to make FTPS data channel encrypted
I am new to FTP. 我是FTP新手。 I have a problem with my FTPSClient program. 我的FTPSClient程序有问题。 Only control channel is encrypted. 仅控制通道被加密。 I need both the control and data channel to be encrypted. 我需要对控制和数据通道进行加密。
public boolean login(String usrName,char[] passwd){
try {
ftpClient = new FTPSClient(protocol,false); // SSL FTP
ftpClient.connect(strHost);
int reply = ftpClient.getReplyCode(); // After connection attempt, you should check the reply code to verify success.
if (!FTPReply.isPositiveCompletion(reply)) {
ftpClient.disconnect();
log.error("FTP server refused connection.");
return false;
}
ftpClient.setBufferSize(1000);
if (!ftpClient.login(strUsrName,new String(passwd))){
ftpClient.logout();
bLoginStatus = false;
return false;
}
else
bLoginStatus = true;
if(iMode == LOCAL_ACTIVE_MODE)
ftpClient.enterLocalActiveMode();
else if(iMode == LOCAL_PASSIVE_MODE)
ftpClient.enterLocalPassiveMode();
} catch (SocketException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch(Throwable t){
t.printStackTrace();
}finally {
if (bLoginStatus == false && ftpClient.isConnected()){
try{
ftpClient.disconnect();
}
catch (IOException f){
// do nothing
}
}
}
if(ftpClient.isConnected())
return true;
else
return false;
}
You need to tell the client to also encrypt the data connection, you can do this (if i recall correctly) with the PROT command: 您需要告诉客户端也加密数据连接,可以使用PROT命令执行此操作(如果我没记错的话):
client.execPBSZ(0);
client.execPROT("P");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.