I am working on app (android) that is supposed to visit website & retrieve some data from there. I was thinking it would be nice to use tor so I would not leave so much info about myself.
I've completed scraping part and everything works. Problem is, i can not make proxy accessing internet. I wanted to use Orbot as proxy. I always get 405 error and text:
"this is an http connect tunnel, not a full http proxy it appears you have configured your browser to use this tor port as an http proxy this is not correct: this port is configured as connect tunnel, not an http proxy. please configure your client accordingly. you can also use https; then the client should automatically use http connect"
Code:
UserAgent agent = new UserAgent();
agent.setProxyHost("127.0.0.1");
agent.setProxyPort(8118);
agent.visit("http://stackoverflow.com");
I've tried
System.setProperty("http.proxyHost", "127.0.0.1");
System.setProperty("http.proxyPort", "8118");
instead of the two middle lines from previous code as well plus few other probably not smart things (: and nothing has helped.
From error text about connect tunnel and proxy I figured problem is somewhere in networking but although I searched about it, I couldn't fix it. Perhaps something in Orbot's settings?
My question is, what am I missing please? :)
Related
I am attempting to view https requests in Fiddler made by a program in inteliJ.
I have been attempting to use the different methods that are posted on the internet. By the way, this is for one-off testing.
These include:
- Programmatically
- This works, but its not scaleable, and we have to add extra code to ignore ssl certificates. I do not want to pursue this path.
System.setProperty("http.proxyHost", "127.0.0.1");
System.setProperty("https.proxyHost", "127.0.0.1");
System.setProperty("http.proxyPort", "8888");
System.setProperty("https.proxyPort", "8888");
Exporting Fiddler cert
This is the most common thing I am seeing, and I think this is the route that I want to go.
Only issue is that once I use keytool and make sure intelij is seeing it (at least I think I am, I am not sure how to confirm), the tests that I am running fail. They ping another port on the server computer, but as soon as they send a request, they fail.
I am not looking to change the proxy service. Right now fiddler is what I need to use.
I also do not want to do this programattically. I have that working, but its not the solution that I want.
Thank you for your help.
I'm having difficulty using Fiddler to diagnose a problem in a Java application to connect to Microsoft Graph's API. Here's my basic environment:
JDK: 1.8.0_131
Apache HttpClient: 4.4
Fiddler: 4.6
The endpoint I'm trying to reach is https://login.microsoftonline.com/common/oauth2/authorize The problem I have is that the traffic is not captured by Fiddler.
I've tried various things as suggested by Googling for this problem, but have not got it to work. In my application, I set the proxy settings as follows:
httpClientBuilder.setProxy(new HttpHost(proxyServer, proxyPort, proxyScheme));
httpClientBuilder.build();
If I use ("127.0.0.1", 8888, "https"): then the error that I see is:
Unrecognized SSL message, plaintext connection?
If I use
("127.0.0.1", 8888, "http"): then the error that I see is: I/O
exception (org.apache.http.conn.UnsupportedSchemeException) caught
when processing request to
{tls}->http://127.0.0.1:8888->https://login.microsoftonline.com:443:
http protocol is not supported
I've tried other things (for example "localhost", "localhost.", and so on as suggested, and setting: -Djsse.enableSNIExtension=false), but so far no luck. Hopefully I am missing something obvious! Thanks for any help.
It turns out that the second configuration for the proxy is the correct one to use (using "http"), but what I had forgotten was that I was setting a ConnectionSocketFactoryRegistry in my HttpClientBuilder. I had not registered a ConnectionSocketFactory for "http" and this caused the second configuration to fail. I added this to the HttpClientBuilder, and now I can see traffic being captured by Fiddler:
connectionSocketFactoryRegistryBuilder.register("http", new PlainConnectionSocketFactory());
I have implemented simple proxy server using Java NIO channels, but have a problem, some sites works perfectly, but other give an error about unknown path or redirect on technical page of its hoster with message the resource doesn't exist. Is it my fault or may be some sites don`t allow proxy?
ProxyServer works as this: I enter 'localhost' and in browser I recive site that was set in code. And request from browser I simply resend on target site at such way:
private void connect(SelectionKey key) throws IOException {
SocketChannel channel = ((SocketChannel) key.channel());
Attachment attachment = (Attachment) key.attachment();
channel.write(attachment.buffer);
}
So 'key' - is SelectionKey of target site and in attachment.buffer I store request that was send to proxy server.
So, something worng with my code or its just closed opportunity to proxy by sites?
Update 1. I suppose, I found a problem. Cause I redirect request from localhost to remote server AS IS so in request in field HOST I have 'localhost'. It seems like some sites ignore this fields, other try to use and redirect to 404 page, cause can't find 'localhost' I`m asking for. So question is how to change field 'Host' in request on destination server name?
The target server doesn't know anything about your NIO code, or whether you are a proxy or a real client.
If you got an error page, the proxy is working, and it is the resource being proxied that is the problem: it doesn't exist, you don't have access, etc. Nothing you can do about that in your code and no reason why you should worry. Just send the error page to the client, same as you would send anything else.
Why is that method called connect() when it doesn't connect and does do something else?
I found a problem. filed HOST after proxy contains 'localhost', so some sites accept it, other not. Replace value of this fields with real host fix the problem.
I have configured a proxy in my java source code as:
systemSettings.put("http.proxyHost", "www.proxyserver.com");
systemSettings.put("http.proxyPort", "8080");
systemSettings.put("http.nonProxyHosts", "10.x.y.z");
Here 10.x.y.z is the actual IP of my weblogic server.
But whenever code tried to connect to weblogic server, I receive error as:
Caused by: java.net.ConnectException: t3://10.x.y.z:7001: Destination
unreachable; nested exception is: java.net.ProtocolException:
unrecognized response from proxy: 'HTTP/1.0 403 Forbidden'; No
available router to destination at
weblogic.rjvm.RJVMFinder.findOrCreateInternal(RJVMFinder.java:216) at
weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:170) at
weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:153) at
weblogic.jndi.WLInitialContextFactoryDelegate$1.run(WLInitialContextFactoryDelegate.java:345)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
at
weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:340)
It seems that setting http.nonProxyHosts is not working as expected. I tried to find solution over the Internet, but most of them says remove proxy settings. I can not remove proxy, as my code tries to connect to some of the Internet URLs. Also note that, weblogic server is on remote machine.
Can you please give me a hint, what must be the issue here?
Have a look at this OTN thread.
From 3rd comment :
You are setting nonProxyHosts, which doesn't exist as a system property, via System.setProperties().
I haven't read all so far, but it seems the system.properties is not the convenient way to set
nonProxyHosts.
Did you tried to set it from command line ?
-Dhttp.nonProxyHosts="*.foo.com|localhost".
I resolved the issue. I had setup the proxy initially when connection with weblogic was setup. So due to some network restrictions I believe it didnt work. In modified code, I used the same 3 lines to setup proxy:
System.setProperty("java.net.useSystemProxies", "false");
System.setProperty("http.proxyHost", "www.proxyserver.com");
System.setProperty("http.proxyPort", "8080");
The only difference is, I did it at exact place where I needed. So for initial connection setup with weblogic proxy wont be used. I also did not have to bypass, weblogic server URL to not to use proxy.
#Arcadien: I appreciate your efforts to help me. Thanks.
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 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?