Skip to content

Do not always act as system proxy #505

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

Closed
ohaucke opened this issue Jan 18, 2024 · 13 comments · Fixed by #530
Closed

Do not always act as system proxy #505

ohaucke opened this issue Jan 18, 2024 · 13 comments · Fixed by #530
Assignees
Labels
enhancement New feature or request work in progress

Comments

@ohaucke
Copy link
Contributor

ohaucke commented Jan 18, 2024

Currently, if you run devproxy on windows, it will always act as a system proxy.
Even though it's on explicit endpoints, it's not always desired.

See: https://github.com/microsoft/dev-proxy/blob/c74843f3a30c46577dfd7b804ea032626711bab9/dev-proxy/ProxyEngine.cs#L122C48-L122C65

My suggestion would be to add an additional option to not act as system proxy.
This way the user can decide which applications should be routed through the proxy (and you don't get asked to install the certificate).

@waldekmastykarz
Copy link
Collaborator

Thanks for the suggestion @ohaucke. I think this is a good idea. We'll need to see if the underlying proxy API that we're using, lets us do this.

As for prompting for installing and registering the certificate, I think that's separate from system-wide proxy registration. If you don't install and trust the cert, you wouldn't be able to decrypt HTTPS traffic. Could you elaborate a bit why you think you'd like to skip it?

@waldekmastykarz waldekmastykarz added enhancement New feature or request needs spec Issue needs specification labels Jan 19, 2024
@ohaucke
Copy link
Contributor Author

ohaucke commented Jan 19, 2024

If you are interested, i could create a PR for that.
I just wanted to check beforehand if that "feature" would be appreciated.

For the implementation:
All we need would be an additional condition in line 119 and 124, something like this:

if (RunTime.IsWindows && _config.ActAsSystemProxy)
{
    // Only explicit proxies can be set as system proxy!
    _proxyServer.SetAsSystemHttpsProxy(_explicitEndPoint);
}
else if (RunTime.IsMac && _config.ActAsSystemProxy)
{
    ToggleSystemProxy(ToggleSystemProxyAction.On, _config.IPAddress, _config.Port);
}
else
{
    _logger.LogWarn("Configure your operating system to use this proxy's port and address");
}

The prompt for installing the certificate is handled by _proxyServer.SetAsSystemHttpsProxy which executes CertificateManager.EnsureRootCertificate(); in titanium web proxy.

You are not required to install the certificate to decrypt the traffic if you ignore tls-errors in the application you are writing (Example: ServerCertificateCustomValidationCallback = delegate { return true; } - FYI: i only set that in debug builds).

I just try to avoid installing additional root certificates.

@waldekmastykarz
Copy link
Collaborator

I appreciate your suggestion and explanation @ohaucke. I suggest, that we'd adjust your proposed change a bit so that we check for the config only once, eg:

if (_config.ActAsSystemProxy)
{
  if (RunTime.IsWindows) ....
}

We'd also do the same check when closing proxy and cleaning up system proxy settings.

@garrytrinder, any additional considerations before we proceed?

@waldekmastykarz waldekmastykarz added needs peer review Issue needs review from other team members and removed needs spec Issue needs specification labels Jan 19, 2024
@ohaucke
Copy link
Contributor Author

ohaucke commented Jan 19, 2024

Sounds good to me 👍
i usually try to avoid nested if statements but that's just me 😆

@waldekmastykarz
Copy link
Collaborator

In this case, I prefer nesting so that we can manage the behavior in one place and avoid inconsistencies.

@waldekmastykarz waldekmastykarz changed the title Do not always act as system proxy on windows Do not always act as system proxy Jan 19, 2024
@waldekmastykarz
Copy link
Collaborator

@garrytrinder
Copy link
Contributor

@garrytrinder, any additional considerations before we proceed?

Nothing to add.

@waldekmastykarz
Copy link
Collaborator

In that case, all yours @ohaucke if you're still interested to work on it 😊

@waldekmastykarz waldekmastykarz added work in progress and removed needs peer review Issue needs review from other team members labels Jan 23, 2024
@ohaucke
Copy link
Contributor Author

ohaucke commented Jan 23, 2024

All right, gonna work on it at this weekend 😄

@waldekmastykarz
Copy link
Collaborator

Awesome! Looking forward to seeing your PR

ohaucke added a commit to ohaucke/dev-proxy that referenced this issue Jan 26, 2024
ohaucke added a commit to ohaucke/dev-proxy that referenced this issue Jan 26, 2024
@ohaucke
Copy link
Contributor Author

ohaucke commented Jan 26, 2024

In this case, I prefer nesting so that we can manage the behavior in one place and avoid inconsistencies.

I've decided against nesting the conditions because it would either result in the same condition multiple times or the same else multiple times.

waldekmastykarz added a commit that referenced this issue Feb 5, 2024
…cert (#530)

* Add --do-not-act-as-system-proxy option #505

* Add --do-not-install-self-signed-cert option #505

* Remove unnecessary launch settings

* Rename launch options to avoid double negations

* Run EnsureRootCertificate only on non-windows OS

* Rework AsSystemProxy condition

* Combine conditions in FirstRunSetup

* Update --as-system-proxy description

* Unify EOL in ProxyHost

* Adds comment

* Update ProxyHost.cs

* Change loading of cert if it should not be installed

---------

Co-authored-by: Waldek Mastykarz <[email protected]>
@ohaucke
Copy link
Contributor Author

ohaucke commented Feb 6, 2024

Done with #530

@waldekmastykarz Thanks for your time and testing :)

@waldekmastykarz
Copy link
Collaborator

And thank you for working with us! 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants