Skip to content

Commit

Permalink
override root cert if specified
Browse files Browse the repository at this point in the history
  • Loading branch information
justcoding121 committed Mar 2, 2016
1 parent dee6d59 commit c244b2b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Titanium.Web.Proxy/ProxyServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Titanium.Web.Proxy
/// </summary>
public partial class ProxyServer
{
private static readonly int BUFFER_SIZE = 8192;

private static readonly char[] SemiSplit = { ';' };

private static readonly string[] ColonSpaceSplit = { ": " };
Expand All @@ -34,17 +34,16 @@ public partial class ProxyServer
private static readonly byte[] ChunkEnd =
Encoding.ASCII.GetBytes(0.ToString("x2") + Environment.NewLine + Environment.NewLine);

public static readonly int BUFFER_SIZE = 8192;
#if NET45
internal static SslProtocols SupportedProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Ssl3;
#else
public static SslProtocols SupportedProtocols = SslProtocols.Tls | SslProtocols.Ssl3;
internal static SslProtocols SupportedProtocols = SslProtocols.Tls | SslProtocols.Ssl3;
#endif

static ProxyServer()
{
CertManager = new CertificateManager("Titanium",
"Titanium Root Certificate Authority");


ProxyEndPoints = new List<ProxyEndPoint>();

Initialize();
Expand All @@ -55,6 +54,7 @@ static ProxyServer()
private static bool certTrusted { get; set; }
private static bool proxyRunning { get; set; }

public static string RootCertificateIssuerName { get; set; }
public static string RootCertificateName { get; set; }

public static event EventHandler<SessionEventArgs> BeforeRequest;
Expand Down Expand Up @@ -123,7 +123,6 @@ public static void SetAsSystemHttpsProxy(ExplicitProxyEndPoint endPoint)
//clear any settings previously added
ProxyEndPoints.OfType<ExplicitProxyEndPoint>().ToList().ForEach(x => x.IsSystemHttpsProxy = false);

RootCertificateName = RootCertificateName ?? "Titanium_Proxy_Test_Root";

//If certificate was trusted by the machine
if (certTrusted)
Expand Down Expand Up @@ -156,6 +155,12 @@ public static void Start()
if (proxyRunning)
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);

if (EnableSsl)
Expand Down

0 comments on commit c244b2b

Please sign in to comment.