[jira] [Commented] (NET-578) FTPS client through http proxy

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[jira] [Commented] (NET-578) FTPS client through http proxy

JIRA jira@apache.org

    [ https://issues.apache.org/jira/browse/NET-578?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16089715#comment-16089715 ]

Johannes Frank commented on NET-578:
------------------------------------

I'm still having the issue with commons-net-3.6 When trying to issue an MLSD.
The problem appears to lie in execPROT in FTPSClient.java:534 - setSocketFactory(new FTPSSocketFactory(context)); triggers setSocketFactory, which sets connProxy to null. In turn, any call that is attempted which requires a data connection to be established actually CIRCUMVENTS the proxy settings (attempting to contact the ftp server directly), which of course fails.

Further note: I'm using PROT P to enforce encryption of the data connections as well, which triggers the else statement. Without explicitly setting PROT, the proxy communication is working as intended.

> FTPS client through http proxy
> ------------------------------
>
>                 Key: NET-578
>                 URL: https://issues.apache.org/jira/browse/NET-578
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.3
>         Environment: Linux 3.0.101-0.21-default x86_64
> Java 1.8 update 45 64-bit
>            Reporter: Jefferson Madalena
>         Attachments: FTPSHTTPClient_source_code.zip
>
>
> I'm trying to develop a Java FTPS client using Apache Commons Net library. To run de code I'm using Java 8, update 45.
> The exception occurs when I'm invoking the method "retrieveFile". I'm not sure, but I belive the connection used to tranfer the file is not using the HTTP proxy specified in code.
> With FileZilla client I can tranfer files using the same configurations.
> How can I fix this problem?
> {code:title=My code|borderStyle=solid}
> // client with explicit security
> FTPSClient ftps = new FTPSClient(false);
> // HTTP proxy configuration
> Proxy proxy = new Proxy(Type.HTTP, new InetSocketAddress("<REMOVED_FOR_SERCURITY>", <REMOVED_FOR_SERCURITY>));
> ftps.setProxy(proxy);
> // to show FTP commands in prompt
> ftps.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out), true));
> // disable remote host verification
> ftps.setRemoteVerificationEnabled(false);
> // trust in ALL
> ftps.setTrustManager(TrustManagerUtils.getAcceptAllTrustManager());
> // send keepAlive every 30 seconds
> ftps.setControlKeepAliveTimeout(10l);
> // data transfer timeout
> ftps.setDataTimeout(30000);
> // connect
> ftps.connect("<REMOVED_FOR_SERCURITY>", <REMOVED_FOR_SERCURITY>);
> ftps.login("<REMOVED_FOR_SERCURITY>", "<REMOVED_FOR_SERCURITY>");
> // config
> ftps.setCharset(Charset.forName("UTF-8"));
> ftps.setBufferSize(0);
> ftps.setFileType(FTP.BINARY_FILE_TYPE);
> ftps.enterLocalPassiveMode();
> ftps.execPROT("P");
> // ... do some operations
> ftps.retrieveFile("/dir1/dir2/fileX.zip", new ByteArrayOutputStream());
> // close
> ftps.logout();
> ftps.disconnect();
> {code}
> The output:
> {noformat}
> 220 (vsFTPd 2.2.2)
> AUTH TLS
> 234 Proceed with negotiation.
> USER *******
> 331 Please specify the password.
> PASS *******
> 230 Login successful.
> TYPE I
> 200 Switching to Binary mode.
> PROT P
> 200 PROT now Private.
> PASV
> 227 Entering Passive Mode (<REMOVED_FOR_SERCURITY>).
> Exception in thread "main" java.net.ConnectException: Connection timed out: connect
>     at java.net.DualStackPlainSocketImpl.connect0(Native Method)
>     at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
>     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
>     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
>     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
>     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
>     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
>     at java.net.Socket.connect(Socket.java:589)
>     at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:656)
>     at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:894)
>     at org.apache.commons.net.ftp.FTPSClient._openDataConnection_(FTPSClient.java:600)
>     at org.apache.commons.net.ftp.FTPClient._retrieveFile(FTPClient.java:1854)
>     at org.apache.commons.net.ftp.FTPClient.retrieveFile(FTPClient.java:1845)
>     at br.com.bat.crm.test.util.FTPSClientTest.main(FTPSClientTest.java:57)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
Loading...