开发者

Connecting to a SOCKS5 proxy to do FTP/S in Java

开发者 https://www.devze.com 2023-01-21 04:53 出处:网络
I\'m writing a job that will connect to a client\'s FTP/S server over my SOCKS5 proxy and I\'m utilizing the Apache Commons Net package. The issue is that my SOCKS proxy is configured to not require a

I'm writing a job that will connect to a client's FTP/S server over my SOCKS5 proxy and I'm utilizing the Apache Commons Net package. The issue is that my SOCKS proxy is configured to not require authentication but I am still getting the following exception:

java.net.SocketException: SOCKS : authentication failed
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:443)
    at java.net.Socket.connect(Socket.java:519)

I've tried setting the java.net.socks.username and password properties to empty strings but I still get it. Is there a way I can tell the 开发者_StackOverflow中文版code to not use authentication? Digging into the underlying source i almost think it's querying the proxy server for the authentication requirement, but I'm not sure.


Alright so the issue was that my SOCKS proxy was set up to ask for authentication but to also accept connections that did not authenticate. We use Dante and while programs like Filezilla are smart enough to iterate through all of the acceptable authentication methods, it seems like the java.net package only goes off the first method supplied. Since my authentication configuration in my sockd.conf file was as follows:

method: username none
user.notprivileged: nobody

java.net was demanding a username and password. I simply flipped the methods to "none username" and both Filezilla and java.net correctly pass through the proxy. It's a bit of an IT solution but whatever gets the code to work, right?

0

精彩评论

暂无评论...
验证码 换一张
取 消