Skip to content
This repository has been archived by the owner on Jul 9, 2023. It is now read-only.
Jehonathan Thomas edited this page Nov 20, 2018 · 56 revisions

Syncing Request & Response

Proxy is asynchronously multi-threaded, so request/response handlers will be fired as soon as we receive data from client/server asynchronously. This won't be in order necessarily. To store data specific to a request/response sequence one can use SessionEventArgs.UserData property.

Firefox

Firefox doesn't look at Windows Certificate Store by default for Root Certificates. It maintains its own Certificate Infrastructure. As such one need to configure Firefox to use Windows Store.

As per below guideline, Firefox should use Windows root certificates if root was added to Local Windows Machine Store. To install in Local Machine Store one need to have local administrator privilege. Alternatively proxy will install root to local machine if it was run as an administrator. In addition, the API flag CERT_SYSTEM_STORE_LOCAL_MACHINE in Firefox needs to be toggled to true. API flags can be modified in Firefox by navigating to about:firefox from Firefox browser URL tab.

https://wiki.mozilla.org/CA:AddRootToFirefox

Mono Support (for Apple Mac OS or Linux)

Mono support is not verified. However we assume it would run in mono, since users have reported so. Of course calls such as SetAsSystemHttpProxy would fail since they make use of windows specific APIs. In Mono we make use of BouncyCastle library to generate Certificates and it is the only option. In Windows we make use of BouncyCastle by default, or optionally native COM calls to faster Windows inbuilt certificate generator, but not recommended due to a bug (see #468). If someone could fix the bug it would be appreciated. This is controlled by below flag.

proxyServer.CertificateEngine = Network.CertificateEngine.DefaultWindows;

.Net Standard Support (for Windows, Apple Mac OS or Linux)

.Net standard is supported and the minimum version required is 1.6. Nuget packages are available with .Net standard support. A sample project is in the repository. Again, Windows specific calls for setting system proxy or anything similar won't work. Similar to Mono, only BouncyCastle is supported as Certificate Maker Engine.

Excluding & Including HTTPS connections

Proxy can relay incoming HTTPS connections without doing decryption when using ExplicitEndPoint. This can be done using OnBeforeTunnelConnect of TransparentEndPoint as follows.

explicitEndPoint.BeforeTunnelConnect += OnBeforeTunnelConnect;

private async Task<bool> OnBeforeTunnelConnect(string hostname)
{
    if (hostname.Contains("google.com") || hostname.Contains("bing.com"))
    {
        //exclude bing.com and google.com from being decrypted
        //instead it will be relayed via a secure TCP tunnel
        return await Task.FromResult(true);
    }
    else
    {
        return await Task.FromResult(false);
    }
}

Custom Root Certificates

One can set Root Certificate used by the proxy using below property.

X509Certificate2 RootCertificate { get; set; }

If the user did not set RootCertificate, we will do the following.

  1. We will check for "rootCert.pfx" in the current working directory.
  2. If it's not found, we will create "rootCert.pfx" and save it to current working directory. The root certificate name will be "Titanium Root Certificate Authority". This is so that we won't create new RootCertificates each time the proxy is started.
  3. Next we will read "rootCert.pfx" as our root certificate.
  4. And finally we will trust the loaded RootCertificate by checking below property. (It's true by default)

public bool TrustRootCertificate { get; set; }

Contribution Guidelines

Code Style

The code style is as follows.

  1. Property and Field names should be camelCase for private
  2. Property and Field names should be PascalCase for public, internal or any other.
  3. Generally method names should be always be in PascalCase. However private method names should be camelCase.
  4. Argument names should be always camelCase.
  5. Local variables should be always camelCase
  6. Class definitions should define private members first (also const), followed by private properties and then public properties (also const) etc. public void Dispose() method is usually placed at the end of class definition.
  7. Use helper classes for methods if relevant to improve readability.

New APIs

Would be nice to discuss any new public APIs before making an effort via PR. Also note this is not intended to be a web debugging proxy. So APIs for timers or other trivial details are avoided mostly. We are focused more on performance.

Supporting the project via funds

As original author of this project and maintainer, I've (@justcoding121) received couple of offers for monetary rewards or donations to either add features or dedicate more time to this project. But due to the legal nature of my work visa in US (H1b), I am unable to volunteer anything more than my spare time. One day when I move to Canada in search of work freedom, that may be a possibility. I recommend to contact @honfika, a good contributor from past for any such offers. (I can give his email address if you contact me via my LinkedIn account).

Dependency Projects

Clone this wiki locally