Unverified Commit 6149ed65 authored by honfika's avatar honfika Committed by GitHub

Merge pull request #722 from justcoding121/master

beta
parents 500ceade 6db82ba8
......@@ -15,6 +15,7 @@ Kindly report only issues/bugs here. For programming help or questions use [Stac
* View/modify/redirect/block requests and responses
* Supports mutual SSL authentication, proxy authentication & automatic upstream proxy detection
* Kerberos/NTLM authentication over HTTP protocols for windows domain
* SOCKS4/5 Proxy support
### Installation
Install by [nuget](https://www.nuget.org/packages/Titanium.Web.Proxy)
......@@ -29,21 +30,21 @@ For stable releases on [stable branch](https://github.com/justcoding121/Titanium
Supports
* .Net Standard 2.0 or above
* .Net Framework 4.6.1 or above
* .NET Standard 2.0 or above
* .NET Framework 4.5 or above
### Development environment
#### Windows
* Visual Studio Code as IDE for .NET core
* Visual Studio 2017/2019 as IDE for .NET framework/.NET core
* Visual Studio Code as IDE for .NET Core
* Visual Studio 2019 as IDE for .NET Framework/.NET Core
#### Mac OS
* Visual Studio Code as IDE for .NET core
* Visual Studio 2017 as IDE for Mono
* Visual Studio Code as IDE for .NET Core
* Visual Studio 2019 as IDE for Mono
#### Linux
* Visual Studio Code as IDE for .NET core
* Visual Studio Code as IDE for .NET Core
* Mono develop as IDE for Mono
### Usage
......@@ -191,7 +192,7 @@ public async Task OnResponse(object sender, SessionEventArgs e)
{
if (e.HttpClient.Response.ResponseStatusCode == "200")
{
if (e.HttpClient.Response.ContentType!=null && e.HttpClient.Response.ContentType.Trim().ToLower().Contains("text/html"))
if (e.HttpClient.Response.ContentType != null && e.HttpClient.Response.ContentType.Trim().ToLower().Contains("text/html"))
{
byte[] bodyBytes = await e.GetResponseBody();
await e.SetResponseBody(bodyBytes);
......@@ -202,7 +203,7 @@ public async Task OnResponse(object sender, SessionEventArgs e)
}
}
if (e.UserData!=null)
if (e.UserData != null)
{
// access request from UserData property where we stored it in RequestHandler
var request = (Request)e.UserData;
......@@ -216,14 +217,14 @@ public Task OnCertificateValidation(object sender, CertificateValidationEventArg
if (e.SslPolicyErrors == System.Net.Security.SslPolicyErrors.None)
e.IsValid = true;
return Task.FromResult(0);
return Task.CompletedTask;
}
// Allows overriding default client certificate selection logic during mutual authentication
public Task OnCertificateSelection(object sender, CertificateSelectionEventArgs e)
{
// set e.clientCertificate to override
return Task.FromResult(0);
return Task.CompletedTask;
}
```
### Note to contributors
......
......@@ -108,6 +108,10 @@
Default.</p>
</td>
</tr>
<tr>
<td id="Titanium_Web_Proxy_Network_CertificateEngine_BouncyCastleFast">BouncyCastleFast</td>
<td></td>
</tr>
<tr>
<td id="Titanium_Web_Proxy_Network_CertificateEngine_DefaultWindows">DefaultWindows</td>
<td><p>Uses Windows Certification Generation API and only valid in Windows OS.
......
......@@ -132,7 +132,7 @@
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_CertificateCacheTimeOutMinutes.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.CertificateCacheTimeOutMinutes%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L257">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L269">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_CertificateCacheTimeOutMinutes_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.CertificateCacheTimeOutMinutes*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_CertificateCacheTimeOutMinutes" data-uid="Titanium.Web.Proxy.Network.CertificateManager.CertificateCacheTimeOutMinutes">CertificateCacheTimeOutMinutes</h4>
......@@ -163,7 +163,7 @@
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_CertificateEngine.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.CertificateEngine%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L161">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L173">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_CertificateEngine_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.CertificateEngine*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_CertificateEngine" data-uid="Titanium.Web.Proxy.Network.CertificateManager.CertificateEngine">CertificateEngine</h4>
......@@ -196,7 +196,7 @@ Mono only support BouncyCastle and it is the default.</p>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_CertificateStorage.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.CertificateStorage%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L242">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L254">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_CertificateStorage_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.CertificateStorage*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_CertificateStorage" data-uid="Titanium.Web.Proxy.Network.CertificateManager.CertificateStorage">CertificateStorage</h4>
......@@ -229,7 +229,7 @@ Implement ICertificateCache interface and assign concrete class here to customiz
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_OverwritePfxFile.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.OverwritePfxFile%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L252">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L264">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_OverwritePfxFile_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.OverwritePfxFile*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_OverwritePfxFile" data-uid="Titanium.Web.Proxy.Network.CertificateManager.OverwritePfxFile">OverwritePfxFile</h4>
......@@ -261,7 +261,7 @@ Implement ICertificateCache interface and assign concrete class here to customiz
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_PfxFilePath.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.PfxFilePath%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L193">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L205">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_PfxFilePath_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.PfxFilePath*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_PfxFilePath" data-uid="Titanium.Web.Proxy.Network.CertificateManager.PfxFilePath">PfxFilePath</h4>
......@@ -296,7 +296,7 @@ Implement ICertificateCache interface and assign concrete class here to customiz
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_PfxPassword.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.PfxPassword%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L184">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L196">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_PfxPassword_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.PfxPassword*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_PfxPassword" data-uid="Titanium.Web.Proxy.Network.CertificateManager.PfxPassword">PfxPassword</h4>
......@@ -328,7 +328,7 @@ Implement ICertificateCache interface and assign concrete class here to customiz
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_RootCertificate.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.RootCertificate%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L221">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L233">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_RootCertificate_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.RootCertificate*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_RootCertificate" data-uid="Titanium.Web.Proxy.Network.CertificateManager.RootCertificate">RootCertificate</h4>
......@@ -359,7 +359,7 @@ Implement ICertificateCache interface and assign concrete class here to customiz
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_RootCertificateIssuerName.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.RootCertificateIssuerName%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L199">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L211">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_RootCertificateIssuerName_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.RootCertificateIssuerName*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_RootCertificateIssuerName" data-uid="Titanium.Web.Proxy.Network.CertificateManager.RootCertificateIssuerName">RootCertificateIssuerName</h4>
......@@ -391,7 +391,7 @@ Implement ICertificateCache interface and assign concrete class here to customiz
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_RootCertificateName.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.RootCertificateName%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L212">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L224">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_RootCertificateName_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.RootCertificateName*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_RootCertificateName" data-uid="Titanium.Web.Proxy.Network.CertificateManager.RootCertificateName">RootCertificateName</h4>
......@@ -426,7 +426,7 @@ Root certificate file will be named as &quot;rootCert.pfx&quot;.</p>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_SaveFakeCertificates.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.SaveFakeCertificates%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L235">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L247">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_SaveFakeCertificates_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.SaveFakeCertificates*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_SaveFakeCertificates" data-uid="Titanium.Web.Proxy.Network.CertificateManager.SaveFakeCertificates">SaveFakeCertificates</h4>
......@@ -458,7 +458,7 @@ Root certificate file will be named as &quot;rootCert.pfx&quot;.</p>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_StorageFlag.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.StorageFlag%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L262">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L274">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_StorageFlag_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.StorageFlag*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_StorageFlag" data-uid="Titanium.Web.Proxy.Network.CertificateManager.StorageFlag">StorageFlag</h4>
......@@ -491,7 +491,7 @@ Root certificate file will be named as &quot;rootCert.pfx&quot;.</p>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_ClearRootCertificate.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.ClearRootCertificate%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L902">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L914">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_ClearRootCertificate_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.ClearRootCertificate*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_ClearRootCertificate" data-uid="Titanium.Web.Proxy.Network.CertificateManager.ClearRootCertificate">ClearRootCertificate()</h4>
......@@ -507,7 +507,7 @@ Root certificate file will be named as &quot;rootCert.pfx&quot;.</p>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_CreateRootCertificate_System_Boolean_.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.CreateRootCertificate(System.Boolean)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L537">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L549">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_CreateRootCertificate_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.CreateRootCertificate*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_CreateRootCertificate_System_Boolean_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.CreateRootCertificate(System.Boolean)">CreateRootCertificate(Boolean)</h4>
......@@ -557,7 +557,7 @@ Root certificate file will be named as &quot;rootCert.pfx&quot;.</p>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_CreateServerCertificate_System_String_.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.CreateServerCertificate(System.String)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L457">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L469">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_CreateServerCertificate_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.CreateServerCertificate*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_CreateServerCertificate_System_String_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.CreateServerCertificate(System.String)">CreateServerCertificate(String)</h4>
......@@ -605,7 +605,7 @@ Root certificate file will be named as &quot;rootCert.pfx&quot;.</p>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_Dispose.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.Dispose%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L267">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L279">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_Dispose_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.Dispose*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_Dispose" data-uid="Titanium.Web.Proxy.Network.CertificateManager.Dispose">Dispose()</h4>
......@@ -621,7 +621,7 @@ Root certificate file will be named as &quot;rootCert.pfx&quot;.</p>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_EnsureRootCertificate.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.EnsureRootCertificate%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L735">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L747">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_EnsureRootCertificate_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.EnsureRootCertificate*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_EnsureRootCertificate" data-uid="Titanium.Web.Proxy.Network.CertificateManager.EnsureRootCertificate">EnsureRootCertificate()</h4>
......@@ -638,7 +638,7 @@ Also makes root certificate trusted based on initial setup from proxy constructo
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_EnsureRootCertificate_System_Boolean_System_Boolean_System_Boolean_.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.EnsureRootCertificate(System.Boolean%2CSystem.Boolean%2CSystem.Boolean)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L766">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L778">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_EnsureRootCertificate_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.EnsureRootCertificate*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_EnsureRootCertificate_System_Boolean_System_Boolean_System_Boolean_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.EnsureRootCertificate(System.Boolean,System.Boolean,System.Boolean)">EnsureRootCertificate(Boolean, Boolean, Boolean)</h4>
......@@ -688,7 +688,7 @@ prompting for UAC if required?</p>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_IsRootCertificateMachineTrusted.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.IsRootCertificateMachineTrusted%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L787">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L799">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_IsRootCertificateMachineTrusted_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.IsRootCertificateMachineTrusted*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_IsRootCertificateMachineTrusted" data-uid="Titanium.Web.Proxy.Network.CertificateManager.IsRootCertificateMachineTrusted">IsRootCertificateMachineTrusted()</h4>
......@@ -719,7 +719,7 @@ prompting for UAC if required?</p>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_IsRootCertificateUserTrusted.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.IsRootCertificateUserTrusted%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L779">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L791">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_IsRootCertificateUserTrusted_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.IsRootCertificateUserTrusted*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_IsRootCertificateUserTrusted" data-uid="Titanium.Web.Proxy.Network.CertificateManager.IsRootCertificateUserTrusted">IsRootCertificateUserTrusted()</h4>
......@@ -750,7 +750,7 @@ prompting for UAC if required?</p>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_LoadRootCertificate.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.LoadRootCertificate%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L607">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L619">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_LoadRootCertificate_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.LoadRootCertificate*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_LoadRootCertificate" data-uid="Titanium.Web.Proxy.Network.CertificateManager.LoadRootCertificate">LoadRootCertificate()</h4>
......@@ -781,7 +781,7 @@ prompting for UAC if required?</p>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_LoadRootCertificate_System_String_System_String_System_Boolean_System_Security_Cryptography_X509Certificates_X509KeyStorageFlags_.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.LoadRootCertificate(System.String%2CSystem.String%2CSystem.Boolean%2CSystem.Security.Cryptography.X509Certificates.X509KeyStorageFlags)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L636">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L648">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_LoadRootCertificate_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.LoadRootCertificate*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_LoadRootCertificate_System_String_System_String_System_Boolean_System_Security_Cryptography_X509Certificates_X509KeyStorageFlags_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.LoadRootCertificate(System.String,System.String,System.Boolean,System.Security.Cryptography.X509Certificates.X509KeyStorageFlags)">LoadRootCertificate(String, String, Boolean, X509KeyStorageFlags)</h4>
......@@ -850,7 +850,7 @@ RootCertificate==null.</p>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_RemoveTrustedRootCertificate_System_Boolean_.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.RemoveTrustedRootCertificate(System.Boolean)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L797">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L809">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_RemoveTrustedRootCertificate_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.RemoveTrustedRootCertificate*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_RemoveTrustedRootCertificate_System_Boolean_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.RemoveTrustedRootCertificate(System.Boolean)">RemoveTrustedRootCertificate(Boolean)</h4>
......@@ -885,7 +885,7 @@ To remove from machine store elevated permissions are required (will fail silent
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_RemoveTrustedRootCertificateAsAdmin_System_Boolean_.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.RemoveTrustedRootCertificateAsAdmin(System.Boolean)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L821">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L833">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_RemoveTrustedRootCertificateAsAdmin_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.RemoveTrustedRootCertificateAsAdmin*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_RemoveTrustedRootCertificateAsAdmin_System_Boolean_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.RemoveTrustedRootCertificateAsAdmin(System.Boolean)">RemoveTrustedRootCertificateAsAdmin(Boolean)</h4>
......@@ -934,7 +934,7 @@ To remove from machine store elevated permissions are required (will fail silent
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_TrustRootCertificate_System_Boolean_.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.TrustRootCertificate(System.Boolean)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L653">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L665">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_TrustRootCertificate_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.TrustRootCertificate*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_TrustRootCertificate_System_Boolean_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.TrustRootCertificate(System.Boolean)">TrustRootCertificate(Boolean)</h4>
......@@ -968,7 +968,7 @@ Machine trust would require elevated permissions (will silently fail otherwise).
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager_TrustRootCertificateAsAdmin_System_Boolean_.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager.TrustRootCertificateAsAdmin(System.Boolean)%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A">Improve this Doc</a>
</span>
<span class="small pull-right mobile-hide">
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L678">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L690">View Source</a>
</span>
<a id="Titanium_Web_Proxy_Network_CertificateManager_TrustRootCertificateAsAdmin_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.TrustRootCertificateAsAdmin*"></a>
<h4 id="Titanium_Web_Proxy_Network_CertificateManager_TrustRootCertificateAsAdmin_System_Boolean_" data-uid="Titanium.Web.Proxy.Network.CertificateManager.TrustRootCertificateAsAdmin(System.Boolean)">TrustRootCertificateAsAdmin(Boolean)</h4>
......@@ -1028,7 +1028,7 @@ Prompts with UAC if elevated permissions are required. Works only on Windows.</p
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/new/master/apiSpec/new?filename=Titanium_Web_Proxy_Network_CertificateManager.md&amp;value=---%0Auid%3A%20Titanium.Web.Proxy.Network.CertificateManager%0Asummary%3A%20'*You%20can%20override%20summary%20for%20the%20API%20here%20using%20*MARKDOWN*%20syntax'%0A---%0A%0A*Please%20type%20below%20more%20information%20about%20this%20API%3A*%0A%0A" class="contribution-link">Improve this Doc</a>
</li>
<li>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L38" class="contribution-link">View Source</a>
<a href="https://github.com/justcoding121/Titanium-Web-Proxy/blob/master/src/Titanium.Web.Proxy/Network/CertificateManager.cs/#L40" class="contribution-link">View Source</a>
</li>
</ul>
</div>
......
......@@ -242,7 +242,7 @@
"api/Titanium.Web.Proxy.Network.CertificateEngine.html": {
"href": "api/Titanium.Web.Proxy.Network.CertificateEngine.html",
"title": "Enum CertificateEngine | Titanium Web Proxy",
"keywords": "Enum CertificateEngine Certificate Engine option. Namespace : Titanium.Web.Proxy.Network Assembly : Titanium.Web.Proxy.dll Syntax public enum CertificateEngine Fields Name Description BouncyCastle Uses BouncyCastle 3rd party library. Default. DefaultWindows Uses Windows Certification Generation API and only valid in Windows OS. Observed to be faster than BouncyCastle. Bug #468 Reported."
"keywords": "Enum CertificateEngine Certificate Engine option. Namespace : Titanium.Web.Proxy.Network Assembly : Titanium.Web.Proxy.dll Syntax public enum CertificateEngine Fields Name Description BouncyCastle Uses BouncyCastle 3rd party library. Default. BouncyCastleFast DefaultWindows Uses Windows Certification Generation API and only valid in Windows OS. Observed to be faster than BouncyCastle. Bug #468 Reported."
},
"api/Titanium.Web.Proxy.Network.CertificateManager.html": {
"href": "api/Titanium.Web.Proxy.Network.CertificateManager.html",
......
......@@ -2913,6 +2913,12 @@ references:
commentId: F:Titanium.Web.Proxy.Network.CertificateEngine.BouncyCastle
fullName: Titanium.Web.Proxy.Network.CertificateEngine.BouncyCastle
nameWithType: CertificateEngine.BouncyCastle
- uid: Titanium.Web.Proxy.Network.CertificateEngine.BouncyCastleFast
name: BouncyCastleFast
href: api/Titanium.Web.Proxy.Network.CertificateEngine.html#Titanium_Web_Proxy_Network_CertificateEngine_BouncyCastleFast
commentId: F:Titanium.Web.Proxy.Network.CertificateEngine.BouncyCastleFast
fullName: Titanium.Web.Proxy.Network.CertificateEngine.BouncyCastleFast
nameWithType: CertificateEngine.BouncyCastleFast
- uid: Titanium.Web.Proxy.Network.CertificateEngine.DefaultWindows
name: DefaultWindows
href: api/Titanium.Web.Proxy.Network.CertificateEngine.html#Titanium_Web_Proxy_Network_CertificateEngine_DefaultWindows
......
......@@ -44,6 +44,10 @@ namespace Titanium.Web.Proxy.Examples.Basic
};
proxyServer.ForwardToUpstreamGateway = true;
proxyServer.CertificateManager.SaveFakeCertificates = true;
//proxyServer.ProxyBasicAuthenticateFunc = async (args, userName, password) =>
//{
// return true;
//};
// this is just to show the functionality, provided implementations use junk value
//proxyServer.GetCustomUpStreamProxyFunc = onGetCustomUpStreamProxyFunc;
......@@ -94,8 +98,11 @@ namespace Titanium.Web.Proxy.Examples.Basic
//proxyServer.UpStreamHttpsProxy = new ExternalProxy("localhost", 8888);
// SOCKS proxy
//proxyServer.UpStreamHttpProxy = new ExternalProxy("46.63.0.17", 4145) { ProxyType = ExternalProxyType.Socks4 };
//proxyServer.UpStreamHttpsProxy = new ExternalProxy("46.63.0.17", 4145) { ProxyType = ExternalProxyType.Socks4 };
//proxyServer.UpStreamHttpProxy = new ExternalProxy("127.0.0.1", 1080)
// { ProxyType = ExternalProxyType.Socks5, UserName = "User1", Password = "Pass" };
//proxyServer.UpStreamHttpsProxy = new ExternalProxy("127.0.0.1", 1080)
// { ProxyType = ExternalProxyType.Socks5, UserName = "User1", Password = "Pass" };
//var socksEndPoint = new SocksProxyEndPoint(IPAddress.Any, 1080, true)
//{
......@@ -167,6 +174,12 @@ namespace Titanium.Web.Proxy.Examples.Basic
e.GetState().PipelineInfo.AppendLine(nameof(onBeforeTunnelConnectRequest) + ":" + hostname);
await writeToConsole("Tunnel to: " + hostname);
var clientLocalIp = e.ClientLocalEndPoint.Address;
if (!clientLocalIp.Equals(IPAddress.Loopback) && !clientLocalIp.Equals(IPAddress.IPv6Loopback))
{
e.HttpClient.UpStreamEndPoint = new IPEndPoint(clientLocalIp, 0);
}
if (hostname.Contains("dropbox.com"))
{
// Exclude Https addresses you don't want to proxy
......@@ -212,7 +225,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
{
e.GetState().PipelineInfo.AppendLine(nameof(onBeforeTunnelConnectResponse) + ":" + e.HttpClient.Request.RequestUri);
return Task.FromResult(false);
return Task.CompletedTask;
}
// intercept & cancel redirect or update requests
......@@ -356,7 +369,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
e.IsValid = true;
}
return Task.FromResult(0);
return Task.CompletedTask;
}
/// <summary>
......@@ -370,7 +383,7 @@ namespace Titanium.Web.Proxy.Examples.Basic
// set e.clientCertificate to override
return Task.FromResult(0);
return Task.CompletedTask;
}
private async Task writeToConsole(string message, ConsoleColor? consoleColor = null)
......
......@@ -21,7 +21,7 @@ namespace WindowsServiceExample
{
// we do all this in here so we can reload settings with a simple restart
_proxyServerInstance = new ProxyServer();
_proxyServerInstance = new ProxyServer(false);
if (Properties.Settings.Default.ListeningPort <= 0 ||
Properties.Settings.Default.ListeningPort > 65535)
......
......@@ -53,7 +53,7 @@ namespace Titanium.Web.Proxy.EventArguments
{
BufferPool = server.BufferPool;
ExceptionFunc = server.ExceptionFunc;
TimeLine["Session Created"] = DateTime.Now;
TimeLine["Session Created"] = DateTime.UtcNow;
CancellationTokenSource = cancellationTokenSource;
......
......@@ -92,7 +92,7 @@ namespace Titanium.Web.Proxy.Http
/// <param name="serverConnection">Instance of <see cref="TcpServerConnection" /></param>
internal void SetConnection(TcpServerConnection serverConnection)
{
serverConnection.LastAccess = DateTime.Now;
serverConnection.LastAccess = DateTime.UtcNow;
connection = serverConnection;
}
......
......@@ -44,7 +44,6 @@ namespace Titanium.Web.Proxy.Network.Certificate
/// Makes the certificate.
/// </summary>
/// <param name="sSubjectCn">The s subject cn.</param>
/// <param name="isRoot">if set to <c>true</c> [is root].</param>
/// <param name="signingCert">The signing cert.</param>
/// <returns>X509Certificate2 instance.</returns>
public X509Certificate2 MakeCertificate(string sSubjectCn, X509Certificate2? signingCert = null)
......
using System;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Pkcs;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Generators;
using Org.BouncyCastle.Crypto.Operators;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Crypto.Prng;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Pkcs;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.X509;
using Titanium.Web.Proxy.Helpers;
using Titanium.Web.Proxy.Shared;
using X509Certificate = Org.BouncyCastle.X509.X509Certificate;
namespace Titanium.Web.Proxy.Network.Certificate
{
/// <summary>
/// Implements certificate generation operations.
/// </summary>
internal class BCCertificateMakerFast : ICertificateMaker
{
private const int certificateValidDays = 1825;
private const int certificateGraceDays = 366;
// The FriendlyName value cannot be set on Unix.
// Set this flag to true when exception detected to avoid further exceptions
private static bool doNotSetFriendlyName;
private readonly ExceptionHandler exceptionFunc;
public AsymmetricCipherKeyPair KeyPair { get; set; }
internal BCCertificateMakerFast(ExceptionHandler exceptionFunc)
{
this.exceptionFunc = exceptionFunc;
KeyPair = GenerateKeyPair();
}
/// <summary>
/// Makes the certificate.
/// </summary>
/// <param name="sSubjectCn">The s subject cn.</param>
/// <param name="signingCert">The signing cert.</param>
/// <returns>X509Certificate2 instance.</returns>
public X509Certificate2 MakeCertificate(string sSubjectCn, X509Certificate2? signingCert = null)
{
return makeCertificateInternal(sSubjectCn, true, signingCert);
}
/// <summary>
/// Generates the certificate.
/// </summary>
/// <param name="subjectName">Name of the subject.</param>
/// <param name="issuerName">Name of the issuer.</param>
/// <param name="validFrom">The valid from.</param>
/// <param name="validTo">The valid to.</param>
/// <param name="subjectKeyPair">The key pair.</param>
/// <param name="signatureAlgorithm">The signature algorithm.</param>
/// <param name="issuerPrivateKey">The issuer private key.</param>
/// <param name="hostName">The host name</param>
/// <returns>X509Certificate2 instance.</returns>
/// <exception cref="PemException">Malformed sequence in RSA private key</exception>
private static X509Certificate2 generateCertificate(string? hostName,
string subjectName,
string issuerName, DateTime validFrom,
DateTime validTo, AsymmetricCipherKeyPair subjectKeyPair,
string signatureAlgorithm = "SHA256WithRSA",
AsymmetricKeyParameter? issuerPrivateKey = null)
{
// Generating Random Numbers
var randomGenerator = new CryptoApiRandomGenerator();
var secureRandom = new SecureRandom(randomGenerator);
// The Certificate Generator
var certificateGenerator = new X509V3CertificateGenerator();
// Serial Number
var serialNumber =
BigIntegers.CreateRandomInRange(BigInteger.One, BigInteger.ValueOf(long.MaxValue), secureRandom);
certificateGenerator.SetSerialNumber(serialNumber);
// Issuer and Subject Name
var subjectDn = new X509Name(subjectName);
var issuerDn = new X509Name(issuerName);
certificateGenerator.SetIssuerDN(issuerDn);
certificateGenerator.SetSubjectDN(subjectDn);
certificateGenerator.SetNotBefore(validFrom);
certificateGenerator.SetNotAfter(validTo);
if (hostName != null)
{
// add subject alternative names
var subjectAlternativeNames = new Asn1Encodable[] { new GeneralName(GeneralName.DnsName, hostName) };
var subjectAlternativeNamesExtension = new DerSequence(subjectAlternativeNames);
certificateGenerator.AddExtension(X509Extensions.SubjectAlternativeName.Id, false,
subjectAlternativeNamesExtension);
}
// Subject Public Key
certificateGenerator.SetPublicKey(subjectKeyPair.Public);
// Set certificate intended purposes to only Server Authentication
certificateGenerator.AddExtension(X509Extensions.ExtendedKeyUsage.Id, false,
new ExtendedKeyUsage(KeyPurposeID.IdKPServerAuth));
if (issuerPrivateKey == null)
{
certificateGenerator.AddExtension(X509Extensions.BasicConstraints.Id, true, new BasicConstraints(true));
}
var signatureFactory = new Asn1SignatureFactory(signatureAlgorithm,
issuerPrivateKey ?? subjectKeyPair.Private, secureRandom);
// Self-sign the certificate
var certificate = certificateGenerator.Generate(signatureFactory);
// Corresponding private key
var privateKeyInfo = PrivateKeyInfoFactory.CreatePrivateKeyInfo(subjectKeyPair.Private);
var seq = (Asn1Sequence)Asn1Object.FromByteArray(privateKeyInfo.ParsePrivateKey().GetDerEncoded());
if (seq.Count != 9)
{
throw new PemException("Malformed sequence in RSA private key");
}
var rsa = RsaPrivateKeyStructure.GetInstance(seq);
var rsaparams = new RsaPrivateCrtKeyParameters(rsa.Modulus, rsa.PublicExponent, rsa.PrivateExponent,
rsa.Prime1, rsa.Prime2, rsa.Exponent1,
rsa.Exponent2, rsa.Coefficient);
// Set private key onto certificate instance
var x509Certificate = withPrivateKey(certificate, rsaparams);
if (!doNotSetFriendlyName)
{
try
{
x509Certificate.FriendlyName = ProxyConstants.CNRemoverRegex.Replace(subjectName, string.Empty);
}
catch (PlatformNotSupportedException)
{
doNotSetFriendlyName = true;
}
}
return x509Certificate;
}
public AsymmetricCipherKeyPair GenerateKeyPair(int keyStrength = 2048)
{
var randomGenerator = new CryptoApiRandomGenerator();
var secureRandom = new SecureRandom(randomGenerator);
var keyGenerationParameters = new KeyGenerationParameters(secureRandom, keyStrength);
var keyPairGenerator = new RsaKeyPairGenerator();
keyPairGenerator.Init(keyGenerationParameters);
return keyPairGenerator.GenerateKeyPair();
}
private static X509Certificate2 withPrivateKey(X509Certificate certificate, AsymmetricKeyParameter privateKey)
{
const string password = "password";
Pkcs12Store store;
if(RunTime.IsRunningOnMono)
{
var builder = new Pkcs12StoreBuilder();
builder.SetUseDerEncoding(true);
store = builder.Build();
}
else
{
store = new Pkcs12Store();
}
var entry = new X509CertificateEntry(certificate);
store.SetCertificateEntry(certificate.SubjectDN.ToString(), entry);
store.SetKeyEntry(certificate.SubjectDN.ToString(), new AsymmetricKeyEntry(privateKey), new[] { entry });
using (var ms = new MemoryStream())
{
store.Save(ms, password.ToCharArray(), new SecureRandom(new CryptoApiRandomGenerator()));
return new X509Certificate2(ms.ToArray(), password, X509KeyStorageFlags.Exportable);
}
}
/// <summary>
/// Makes the certificate internal.
/// </summary>
/// <param name="hostName">hostname for certificate</param>
/// <param name="subjectName">The full subject.</param>
/// <param name="validFrom">The valid from.</param>
/// <param name="validTo">The valid to.</param>
/// <param name="signingCertificate">The signing certificate.</param>
/// <returns>X509Certificate2 instance.</returns>
/// <exception cref="System.ArgumentException">
/// You must specify a Signing Certificate if and only if you are not creating a
/// root.
/// </exception>
private X509Certificate2 makeCertificateInternal(string hostName, string subjectName,
DateTime validFrom, DateTime validTo, X509Certificate2? signingCertificate)
{
if (signingCertificate == null)
{
return generateCertificate(null, subjectName, subjectName, validFrom, validTo, KeyPair);
}
var kp = DotNetUtilities.GetKeyPair(signingCertificate.PrivateKey);
return generateCertificate(hostName, subjectName, signingCertificate.Subject, validFrom, validTo, KeyPair,
issuerPrivateKey: kp.Private);
}
/// <summary>
/// Makes the certificate internal.
/// </summary>
/// <param name="subject">The s subject cn.</param>
/// <param name="switchToMtaIfNeeded">if set to <c>true</c> [switch to MTA if needed].</param>
/// <param name="signingCert">The signing cert.</param>
/// <returns>X509Certificate2.</returns>
private X509Certificate2 makeCertificateInternal(string subject,
bool switchToMtaIfNeeded, X509Certificate2? signingCert = null)
{
return makeCertificateInternal(subject, $"CN={subject}",
DateTime.UtcNow.AddDays(-certificateGraceDays), DateTime.UtcNow.AddDays(certificateValidDays),
signingCert);
}
}
}
......@@ -105,7 +105,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
// KeyLength
const int keyLength = 2048;
var now = DateTime.Now;
var now = DateTime.UtcNow;
var graceTime = now.AddDays(graceDays);
var certificate = makeCertificate(sSubjectCN, fullSubject, keyLength, hashAlgo, graceTime,
now.AddDays(validDays), signingCertificate);
......
......@@ -24,6 +24,8 @@ namespace Titanium.Web.Proxy.Network
/// </summary>
BouncyCastle = 0,
BouncyCastleFast = 2,
/// <summary>
/// Uses Windows Certification Generation API and only valid in Windows OS.
/// Observed to be faster than BouncyCastle.
......@@ -68,9 +70,19 @@ namespace Titanium.Web.Proxy.Network
{
if (certEngineValue == null)
{
certEngineValue = engine == CertificateEngine.BouncyCastle
? (ICertificateMaker)new BCCertificateMaker(ExceptionFunc)
: new WinCertificateMaker(ExceptionFunc);
switch (engine)
{
case CertificateEngine.BouncyCastle:
certEngineValue = new BCCertificateMaker(ExceptionFunc);
break;
case CertificateEngine.BouncyCastleFast:
certEngineValue = new BCCertificateMakerFast(ExceptionFunc);
break;
case CertificateEngine.DefaultWindows:
default:
certEngineValue = new WinCertificateMaker(ExceptionFunc);
break;
}
}
return certEngineValue;
......@@ -459,7 +471,7 @@ namespace Titanium.Web.Proxy.Network
// check in cache first
if (cachedCertificates.TryGetValue(certificateName, out var cached))
{
cached.LastAccess = DateTime.Now;
cached.LastAccess = DateTime.UtcNow;
return cached.Certificate;
}
......@@ -498,7 +510,7 @@ namespace Titanium.Web.Proxy.Network
var cancellationToken = clearCertificatesTokenSource.Token;
while (!cancellationToken.IsCancellationRequested)
{
var cutOff = DateTime.Now.AddMinutes(-CertificateCacheTimeOutMinutes);
var cutOff = DateTime.UtcNow.AddMinutes(-CertificateCacheTimeOutMinutes);
var outdated = cachedCertificates.Where(x => x.Value.LastAccess < cutOff).ToList();
......
......@@ -241,7 +241,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
if (cache.TryGetValue(cacheKey, out var existingConnections))
{
// +3 seconds for potential delay after getting connection
var cutOff = DateTime.Now.AddSeconds(-proxyServer.ConnectionTimeOutSeconds + 3);
var cutOff = DateTime.UtcNow.AddSeconds(-proxyServer.ConnectionTimeOutSeconds + 3);
while (existingConnections.Count > 0)
{
if (existingConnections.TryDequeue(out var recentConnection))
......@@ -350,7 +350,7 @@ retry:
if (sessionArgs != null)
{
sessionArgs.TimeLine["Dns Resolved"] = DateTime.Now;
sessionArgs.TimeLine["Dns Resolved"] = DateTime.UtcNow;
}
Array.Sort(ipAddresses, (x, y) => x.AddressFamily.CompareTo(y.AddressFamily));
......@@ -458,7 +458,7 @@ retry:
if (newUpstreamProxy != null)
{
sessionArgs.CustomUpStreamProxyUsed = newUpstreamProxy;
sessionArgs.TimeLine["Retrying Upstream Proxy Connection"] = DateTime.Now;
sessionArgs.TimeLine["Retrying Upstream Proxy Connection"] = DateTime.UtcNow;
return await createServerConnection(remoteHostName, remotePort, httpVersion, isHttps, sslProtocol, applicationProtocols, isConnect, proxyServer, sessionArgs, upStreamEndPoint, externalProxy, cacheKey, cancellationToken);
}
}
......@@ -468,7 +468,7 @@ retry:
if (sessionArgs != null)
{
sessionArgs.TimeLine["Connection Established"] = DateTime.Now;
sessionArgs.TimeLine["Connection Established"] = DateTime.UtcNow;
}
await proxyServer.InvokeServerConnectionCreateEvent(tcpServerSocket);
......@@ -532,7 +532,7 @@ retry:
if (sessionArgs != null)
{
sessionArgs.TimeLine["HTTPS Established"] = DateTime.Now;
sessionArgs.TimeLine["HTTPS Established"] = DateTime.UtcNow;
}
}
}
......@@ -570,7 +570,7 @@ retry:
return;
}
connection.LastAccess = DateTime.Now;
connection.LastAccess = DateTime.UtcNow;
try
{
......@@ -634,7 +634,7 @@ retry:
{
try
{
var cutOff = DateTime.Now.AddSeconds(-Server.ConnectionTimeOutSeconds);
var cutOff = DateTime.UtcNow.AddSeconds(-Server.ConnectionTimeOutSeconds);
foreach (var item in cache)
{
var queue = item.Value;
......
......@@ -20,7 +20,7 @@ namespace Titanium.Web.Proxy.Network.Tcp
Version version, IExternalProxy? upStreamProxy, IPEndPoint? upStreamEndPoint, string cacheKey)
{
TcpSocket = tcpSocket;
LastAccess = DateTime.Now;
LastAccess = DateTime.UtcNow;
this.proxyServer = proxyServer;
this.proxyServer.UpdateServerConnectionCount(true);
Stream = stream;
......
......@@ -43,7 +43,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
Credentials = new Common.SecurityHandle(0);
Context = new Common.SecurityHandle(0);
LastSeen = DateTime.Now;
LastSeen = DateTime.UtcNow;
AuthState = WinAuthState.UNAUTHORIZED;
}
......@@ -56,7 +56,7 @@ namespace Titanium.Web.Proxy.Network.WinAuth.Security
internal void UpdatePresence()
{
LastSeen = DateTime.Now;
LastSeen = DateTime.UtcNow;
}
}
}
......@@ -279,7 +279,7 @@ namespace Titanium.Web.Proxy
// set the connection and send request headers
args.HttpClient.SetConnection(connection);
args.TimeLine["Connection Ready"] = DateTime.Now;
args.TimeLine["Connection Ready"] = DateTime.UtcNow;
if (args.HttpClient.Request.UpgradeToWebSocket)
{
......@@ -335,7 +335,7 @@ namespace Titanium.Web.Proxy
}
}
args.TimeLine["Request Sent"] = DateTime.Now;
args.TimeLine["Request Sent"] = DateTime.UtcNow;
// parse and send response
await handleHttpSessionResponse(args);
......@@ -374,7 +374,7 @@ namespace Titanium.Web.Proxy
/// <returns></returns>
private async Task onBeforeRequest(SessionEventArgs args)
{
args.TimeLine["Request Received"] = DateTime.Now;
args.TimeLine["Request Received"] = DateTime.UtcNow;
if (BeforeRequest != null)
{
......
......@@ -32,7 +32,7 @@ namespace Titanium.Web.Proxy
await args.HttpClient.ReceiveResponse(cancellationToken);
}
args.TimeLine["Response Received"] = DateTime.Now;
args.TimeLine["Response Received"] = DateTime.UtcNow;
var response = args.HttpClient.Response;
args.ReRequest = false;
......@@ -122,7 +122,7 @@ namespace Titanium.Web.Proxy
}
}
args.TimeLine["Response Sent"] = DateTime.Now;
args.TimeLine["Response Sent"] = DateTime.UtcNow;
}
/// <summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment