Commit c244b2b6 authored by titanium007's avatar titanium007

override root cert if specified

parent dee6d59f
...@@ -21,7 +21,7 @@ namespace Titanium.Web.Proxy ...@@ -21,7 +21,7 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public partial class ProxyServer public partial class ProxyServer
{ {
private static readonly int BUFFER_SIZE = 8192;
private static readonly char[] SemiSplit = { ';' }; private static readonly char[] SemiSplit = { ';' };
private static readonly string[] ColonSpaceSplit = { ": " }; private static readonly string[] ColonSpaceSplit = { ": " };
...@@ -34,17 +34,16 @@ namespace Titanium.Web.Proxy ...@@ -34,17 +34,16 @@ namespace Titanium.Web.Proxy
private static readonly byte[] ChunkEnd = private static readonly byte[] ChunkEnd =
Encoding.ASCII.GetBytes(0.ToString("x2") + Environment.NewLine + Environment.NewLine); Encoding.ASCII.GetBytes(0.ToString("x2") + Environment.NewLine + Environment.NewLine);
public static readonly int BUFFER_SIZE = 8192;
#if NET45 #if NET45
internal static SslProtocols SupportedProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Ssl3; internal static SslProtocols SupportedProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Ssl3;
#else #else
public static SslProtocols SupportedProtocols = SslProtocols.Tls | SslProtocols.Ssl3; internal static SslProtocols SupportedProtocols = SslProtocols.Tls | SslProtocols.Ssl3;
#endif #endif
static ProxyServer() static ProxyServer()
{ {
CertManager = new CertificateManager("Titanium",
"Titanium Root Certificate Authority");
ProxyEndPoints = new List<ProxyEndPoint>(); ProxyEndPoints = new List<ProxyEndPoint>();
Initialize(); Initialize();
...@@ -55,6 +54,7 @@ namespace Titanium.Web.Proxy ...@@ -55,6 +54,7 @@ namespace Titanium.Web.Proxy
private static bool certTrusted { get; set; } private static bool certTrusted { get; set; }
private static bool proxyRunning { get; set; } private static bool proxyRunning { get; set; }
public static string RootCertificateIssuerName { get; set; }
public static string RootCertificateName { get; set; } public static string RootCertificateName { get; set; }
public static event EventHandler<SessionEventArgs> BeforeRequest; public static event EventHandler<SessionEventArgs> BeforeRequest;
...@@ -123,7 +123,6 @@ namespace Titanium.Web.Proxy ...@@ -123,7 +123,6 @@ namespace Titanium.Web.Proxy
//clear any settings previously added //clear any settings previously added
ProxyEndPoints.OfType<ExplicitProxyEndPoint>().ToList().ForEach(x => x.IsSystemHttpsProxy = false); ProxyEndPoints.OfType<ExplicitProxyEndPoint>().ToList().ForEach(x => x.IsSystemHttpsProxy = false);
RootCertificateName = RootCertificateName ?? "Titanium_Proxy_Test_Root";
//If certificate was trusted by the machine //If certificate was trusted by the machine
if (certTrusted) if (certTrusted)
...@@ -156,6 +155,12 @@ namespace Titanium.Web.Proxy ...@@ -156,6 +155,12 @@ namespace Titanium.Web.Proxy
if (proxyRunning) if (proxyRunning)
throw new Exception("Proxy is already running."); throw new Exception("Proxy is already running.");
RootCertificateName = RootCertificateName ?? "Titanium Root Certificate Authority";
RootCertificateIssuerName = RootCertificateIssuerName ?? "Titanium";
CertManager = new CertificateManager(RootCertificateIssuerName,
RootCertificateName);
EnableSsl = ProxyEndPoints.Any(x => x.EnableSsl); EnableSsl = ProxyEndPoints.Any(x => x.EnableSsl);
if (EnableSsl) if (EnableSsl)
......
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