Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream HTTPS #2253

Closed
JakeAustwick opened this issue Apr 21, 2017 · 8 comments
Closed

Upstream HTTPS #2253

JakeAustwick opened this issue Apr 21, 2017 · 8 comments
Labels
kind/triage Unclassified issues

Comments

@JakeAustwick
Copy link

I also posted this on Discourse, but I'm posting it here because I believe it to be a bug.

I have my script changing the upstream proxy for HTTP connections, but it seems to fail for HTTPS connections. Here's a basic stripped down example.

https://gist.github.com/JakeAustwick/c3116d86f4483d1acede4420f02efb72

The script works fine for http://api.ipify.org/, but fails for https://api.ipify.org/. With HTTPS I see the following, which shows the upstream proxy wasn't changed.

Server connection to default_proxy:8888 failed: Error connecting to "default_proxy": [Errno 8] nodename nor servname provided, or not known

Running Command:
mitmdump -s utilities/proxy_redirects.py -U http://default_proxy:8888

Platform / Library Version ( I also tested on Ubuntu):

mitmdump --version
Mitmproxy version: 2.0.1 (release version) 
Python version: 3.6.1
Platform: Darwin-14.5.0-x86_64-i386-64bit
SSL version: OpenSSL 1.1.0e 16 Feb 2017
Mac version: 10.10.5 ('', '', '') x86_64
@JakeAustwick JakeAustwick changed the title Upstream SSL Upstream HTTPS Apr 21, 2017
@Kriechi
Copy link
Member

Kriechi commented Apr 21, 2017

The error messages indicates that it can't resolve default_proxy. Is this a valid DNS name in your environment? Can you try and directly use the IP, e.g., -U http://192.168.1.1:8888?

@mhils mhils added the kind/triage Unclassified issues label Apr 21, 2017
@JakeAustwick
Copy link
Author

@Kriechi Sorry, maybe I didn't explain well enough. The issue is that it shouldn't be using default_proxy at all. Look at the code, the proxy should always get changed to a different one. So the one I'm passing on the command line should be irrelevant.

@mhils
Copy link
Member

mhils commented Apr 21, 2017

the proxy should always get changed to a different one.

This is not true for the initial CONNECT request: https://gist.github.com/JakeAustwick/c3116d86f4483d1acede4420f02efb72#file-proxy-py-L21-L22

@JakeAustwick
Copy link
Author

@mhils I tried it without that line too; same issue.

I actually only have those lines because they were from an online example. Is there some kind of technical reason why I need those two lines, and the CONNECT can't go through one of my upstream proxies?

@mhils
Copy link
Member

mhils commented Apr 21, 2017

@JakeAustwick
Copy link
Author

@mhils The comment suggests that doing this is only required if I need access to the request data to make the proxy choice, right?

I have the same issue with the following code though, with the CONNECT line removed (because I'm just using a random proxy, no request data needed).

https://gist.github.com/JakeAustwick/af0bc5a5052b2ff8ec423a9c6ca49b97

@mhils
Copy link
Member

mhils commented Apr 21, 2017

@mhils The comment suggests that doing this is only required if I need access to the request data to make the proxy choice, right?

If you don't redirect before the CONNECT request, said request will be sent to the default server. Whatsoever, looking at the code, this won't fix your problem. We always establish a connection with the default host here. I'm not exactly sure why that is the case, just calling self.set_server(address) might enough at this point. Not sure, maybe that breaks some hidden invariants. Feel free to try that out and submit a PR if it works for you.

@mhils mhils closed this as completed May 2, 2017
@ChillVibesMushroom

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/triage Unclassified issues
Projects
None yet
Development

No branches or pull requests

4 participants