@@ -116,6 +116,7 @@ public class FTP extends Task implements FTPTaskConfig {
116
116
private String password ;
117
117
private String account ;
118
118
private boolean useFtps = false ;
119
+ private boolean useSecureDataChannel = false ;
119
120
private HostnameVerifier hostnameVerifier ;
120
121
private File listing ;
121
122
private boolean binary = true ;
@@ -1277,6 +1278,15 @@ public void setUseFtps(boolean useFtps) {
1277
1278
this .useFtps = useFtps ;
1278
1279
}
1279
1280
1281
+ /**
1282
+ * Whether to use secure data channel when using FTPS
1283
+ *
1284
+ * @since 1.10.15
1285
+ */
1286
+ public void setUseSecureDataChannel (boolean useSecureDataChannel ) {
1287
+ this .useSecureDataChannel = useSecureDataChannel ;
1288
+ }
1289
+
1280
1290
public void add (HostnameVerifier hostnameVerifier ) {
1281
1291
this .hostnameVerifier = hostnameVerifier ;
1282
1292
}
@@ -2575,6 +2585,17 @@ public void execute() throws BuildException {
2575
2585
ftp .getReplyString ());
2576
2586
}
2577
2587
}
2588
+ // if it is FTPS and secure data channel is desired, then we exec "PROT P"
2589
+ // command to enable secure data channel, for the lifetime of this client
2590
+ if (useFtps && useSecureDataChannel ) {
2591
+ FTPSClient ftps = (FTPSClient ) ftp ;
2592
+ try {
2593
+ ftps .execPROT ("P" ); // P implies PRIVATE and enables encryption
2594
+ } catch (IOException e ) {
2595
+ throw new BuildException ("failed to enable secure data channel: " + e , e );
2596
+ }
2597
+ log ("enabled secure data channel" , Project .MSG_VERBOSE );
2598
+ }
2578
2599
2579
2600
// If an initial command was configured then send it.
2580
2601
// Some FTP servers offer different modes of operation,
0 commit comments