Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit 0246b70

Browse files
committed
override root cert if specified
1 parent 19aa3b8 commit 0246b70

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Titanium.Web.Proxy/ProxyServer.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace Titanium.Web.Proxy
2121
/// </summary>
2222
public partial class ProxyServer
2323
{
24-
private static readonly int BUFFER_SIZE = 8192;
24+
2525
private static readonly char[] SemiSplit = { ';' };
2626

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

37+
public static readonly int BUFFER_SIZE = 8192;
3738
#if NET45
3839
internal static SslProtocols SupportedProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Ssl3;
3940
#else
40-
public static SslProtocols SupportedProtocols = SslProtocols.Tls | SslProtocols.Ssl3;
41+
internal static SslProtocols SupportedProtocols = SslProtocols.Tls | SslProtocols.Ssl3;
4142
#endif
4243

4344
static ProxyServer()
4445
{
45-
CertManager = new CertificateManager("Titanium",
46-
"Titanium Root Certificate Authority");
47-
46+
4847
ProxyEndPoints = new List<ProxyEndPoint>();
4948

5049
Initialize();
@@ -55,6 +54,7 @@ static ProxyServer()
5554
private static bool certTrusted { get; set; }
5655
private static bool proxyRunning { get; set; }
5756

57+
public static string RootCertificateIssuerName { get; set; }
5858
public static string RootCertificateName { get; set; }
5959

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

126-
RootCertificateName = RootCertificateName ?? "Titanium_Proxy_Test_Root";
127126

128127
//If certificate was trusted by the machine
129128
if (certTrusted)
@@ -156,6 +155,12 @@ public static void Start()
156155
if (proxyRunning)
157156
throw new Exception("Proxy is already running.");
158157

158+
RootCertificateName = RootCertificateName ?? "Titanium Root Certificate Authority";
159+
RootCertificateIssuerName = RootCertificateIssuerName ?? "Titanium";
160+
161+
CertManager = new CertificateManager(RootCertificateIssuerName,
162+
RootCertificateName);
163+
159164
EnableSsl = ProxyEndPoints.Any(x => x.EnableSsl);
160165

161166
if (EnableSsl)

0 commit comments

Comments
 (0)