Commit 6a9e1839 authored by justcoding121's avatar justcoding121

cleanup

parent 3e3698bc
......@@ -32,8 +32,10 @@ namespace Titanium.Web.Proxy.Examples.Basic
proxyServer = new ProxyServer();
//generate root certificate without storing it in file system
//proxyServer.CertificateManager.CreateTrustedRootCertificate(false);
//proxyServer.CertificateManager.CreateRootCertificate(false);
//proxyServer.CertificateManager.TrustRootCertificate();
//proxyServer.CertificateManager.TrustRootCertificateAsAdmin();
proxyServer.ExceptionFunc = exception => Console.WriteLine(exception.Message);
proxyServer.ForwardToUpstreamGateway = true;
......
......@@ -56,7 +56,7 @@ namespace Titanium.Web.Proxy.UnitTests
mgr.CertificateEngine = CertificateEngine.DefaultWindows;
mgr.CreateRootCertificate(true);
mgr.TrustRootCertificate();
mgr.TrustRootCertificate(true);
mgr.ClearIdleCertificates();
for (int i = 0; i < 5; i++)
......@@ -71,7 +71,7 @@ namespace Titanium.Web.Proxy.UnitTests
}
await Task.WhenAll(tasks.ToArray());
mgr.RemoveTrustedRootCertificate();
mgr.RemoveTrustedRootCertificate(true);
mgr.StopClearIdleCertificates();
}
}
......
......@@ -17,6 +17,7 @@ using Org.BouncyCastle.Pkcs;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.X509;
using Titanium.Web.Proxy.Shared;
namespace Titanium.Web.Proxy.Network.Certificate
{
......@@ -25,8 +26,6 @@ namespace Titanium.Web.Proxy.Network.Certificate
/// </summary>
internal class BCCertificateMaker : ICertificateMaker
{
public static readonly Regex CNRemoverRegex = new Regex(@"^CN\s*=\s*", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private const int certificateValidDays = 1825;
private const int certificateGraceDays = 366;
......@@ -149,7 +148,7 @@ namespace Titanium.Web.Proxy.Network.Certificate
{
try
{
x509Certificate.FriendlyName = CNRemoverRegex.Replace(subjectName, string.Empty);
x509Certificate.FriendlyName = ProxyConstants.CNRemoverRegex.Replace(subjectName, string.Empty);
}
catch (PlatformNotSupportedException)
{
......
......@@ -245,8 +245,8 @@ namespace Titanium.Web.Proxy
}
CertificateManager = new CertificateManager(ExceptionFunc);
CertificateManager.TrustRoot = trustRootCertificate;
CertificateManager.TrustRootAsAdministrator = trustRootCertificateAsAdmin;
CertificateManager.UserTrustRoot = trustRootCertificate;
CertificateManager.MachineTrustRootAsAdministrator = trustRootCertificateAsAdmin;
if (rootCertificateName != null)
{
......
namespace Titanium.Web.Proxy.Shared
using System.Text.RegularExpressions;
namespace Titanium.Web.Proxy.Shared
{
/// <summary>
/// Literals shared by Proxy Server
......@@ -13,5 +15,7 @@
internal static readonly char[] EqualSplit = { '=' };
internal static readonly byte[] NewLine = {(byte)'\r', (byte)'\n' };
public static readonly Regex CNRemoverRegex = new Regex(@"^CN\s*=\s*", RegexOptions.IgnoreCase | RegexOptions.Compiled);
}
}
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