-
Notifications
You must be signed in to change notification settings - Fork 617
Home
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 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 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 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.
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);
}
}
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.
- We will check for "rootCert.pfx" in the current working directory first.
- 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.
- Next we will read the "rootCert.pfx" as our root certificate.
- And finally we will Trust the loaded RootCertificate by checking below existing property. (Its true by default)
public bool TrustRootCertificate { get; set; }
The code style is as follows.
- Property and Field names should be camelCase for private
- Property and Field names should be PascalCase for public, internal or any other.
- Generally method names should be always be in PascalCase. However private method names should be camelCase.
- Argument names should be always camelCase.
- Local variables should be always camelCase
- Class definitions should define private members first (also const), followed by private properties and then public properties (also const) etc.
- Use helper classes for methods if relevant to improve readability.
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.
http代理