Skip to content
This repository has been archived by the owner on Jul 9, 2023. It is now read-only.
justcoding121 edited this page May 26, 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 also 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 is run as an administrator user. 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 native COM calls, or optionally BouncyCastle. This is controlled by below flag.

proxyServer.CertificateEngine = Network.CertificateEngine.BouncyCastle;

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

.Net standard is supported and minimum version required is 1.6. Nuget packages are available with .Net standard 1.6 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 the Root Certificate used by proxy by using below property.

X509Certificate2 RootCertificate { get; set; }

And if the user do not set RootCertificate, then we will do the following.

  1. We will check for "rootCert.pfx" in the current working directory first.
  2. If its not found there, then we will create "rootCert.pfx" and save it in current working directory. The root certificate name will be "Titanium Root Certificate Authority". This is so that we don't create new RootCertificates each time the proxy is started and RootCertificate is not set.
  3. Next we will read the "rootCert.pfx" as our root certificate.
  4. And finally we will Trust the loaded RootCertificate by checking below existing property. (Its 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.
  7. Use helper classes for methods if relevant to improve readability.

New APIs

Would be nice to discuss any new public API to the project before making an effort via PR. Also please 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.

Dependency Projects

Clone this wiki locally