Commit 648a5d28 authored by justcoding121's avatar justcoding121

rename certificateCacheManager => certificateManager

parent a0a6e678
...@@ -31,9 +31,9 @@ namespace Titanium.Web.Proxy.Network ...@@ -31,9 +31,9 @@ namespace Titanium.Web.Proxy.Network
/// </summary> /// </summary>
internal class CertificateManager : IDisposable internal class CertificateManager : IDisposable
{ {
private const string DefaultRootCertificateIssuer = "Titanium"; private const string defaultRootCertificateIssuer = "Titanium";
private const string DefaultRootRootCertificateName = "Titanium Root Certificate Authority"; private const string defaultRootRootCertificateName = "Titanium Root Certificate Authority";
private readonly ICertificateMaker certEngine; private readonly ICertificateMaker certEngine;
...@@ -70,8 +70,8 @@ namespace Titanium.Web.Proxy.Network ...@@ -70,8 +70,8 @@ namespace Titanium.Web.Proxy.Network
certEngine = new WinCertificateMaker(); certEngine = new WinCertificateMaker();
} }
Issuer = issuer ?? DefaultRootCertificateIssuer; Issuer = issuer ?? defaultRootCertificateIssuer;
RootCertificateName = rootCertificateName ?? DefaultRootRootCertificateName; RootCertificateName = rootCertificateName ?? defaultRootRootCertificateName;
certificateCache = new ConcurrentDictionary<string, CachedCertificate>(); certificateCache = new ConcurrentDictionary<string, CachedCertificate>();
} }
......
...@@ -32,7 +32,7 @@ namespace Titanium.Web.Proxy ...@@ -32,7 +32,7 @@ namespace Titanium.Web.Proxy
/// <summary> /// <summary>
/// Manages certificates used by this proxy /// Manages certificates used by this proxy
/// </summary> /// </summary>
private CertificateManager certificateCacheManager { get; set; } private CertificateManager certificateManager { get; set; }
/// <summary> /// <summary>
/// An default exception log func /// An default exception log func
...@@ -74,35 +74,37 @@ namespace Titanium.Web.Proxy ...@@ -74,35 +74,37 @@ namespace Titanium.Web.Proxy
/// </summary> /// </summary>
public X509Certificate2 RootCertificate public X509Certificate2 RootCertificate
{ {
get { return certificateCacheManager.RootCertificate; } get { return certificateManager.RootCertificate; }
set { certificateCacheManager.RootCertificate = value; } set { certificateManager.RootCertificate = value; }
} }
/// <summary> /// <summary>
/// Name of the root certificate issuer /// Name of the root certificate issuer
/// (This is valid only when RootCertificate property is not set)
/// </summary> /// </summary>
public string RootCertificateIssuerName public string RootCertificateIssuerName
{ {
get { return certificateCacheManager.Issuer; } get { return certificateManager.Issuer; }
set set
{ {
CreateCertificateCacheManager(certificateCacheManager.RootCertificateName, value); CreateCertificateCacheManager(certificateManager.RootCertificateName, value);
certValidated = null; certValidated = null;
} }
} }
/// <summary> /// <summary>
/// Name of the root certificate /// Name of the root certificate
/// (This is valid only when RootCertificate property is not set)
/// If no certificate is provided then a default Root Certificate will be created and used /// If no certificate is provided then a default Root Certificate will be created and used
/// The provided root certificate has to be in the proxy exe directory with the private key /// The provided root certificate will be stored in proxy exe directory with the private key
/// The root certificate file should be named as "rootCert.pfx" /// Root certificate file will be named as "rootCert.pfx"
/// </summary> /// </summary>
public string RootCertificateName public string RootCertificateName
{ {
get { return certificateCacheManager.RootCertificateName; } get { return certificateManager.RootCertificateName; }
set set
{ {
CreateCertificateCacheManager(value, certificateCacheManager.Issuer); CreateCertificateCacheManager(value, certificateManager.Issuer);
certValidated = null; certValidated = null;
} }
} }
...@@ -447,14 +449,14 @@ namespace Titanium.Web.Proxy ...@@ -447,14 +449,14 @@ namespace Titanium.Web.Proxy
Listen(endPoint); Listen(endPoint);
} }
certificateCacheManager.ClearIdleCertificates(CertificateCacheTimeOutMinutes); certificateManager.ClearIdleCertificates(CertificateCacheTimeOutMinutes);
proxyRunning = true; proxyRunning = true;
} }
private void CreateCertificateCacheManager(string rootCertificateName, string rootCertificateIssuerName) private void CreateCertificateCacheManager(string rootCertificateName, string rootCertificateIssuerName)
{ {
certificateCacheManager = new CertificateManager(CertificateEngine, certificateManager = new CertificateManager(CertificateEngine,
rootCertificateIssuerName, rootCertificateName, ExceptionFunc); rootCertificateIssuerName, rootCertificateName, ExceptionFunc);
} }
...@@ -462,11 +464,11 @@ namespace Titanium.Web.Proxy ...@@ -462,11 +464,11 @@ namespace Titanium.Web.Proxy
{ {
if (!certValidated.HasValue) if (!certValidated.HasValue)
{ {
certValidated = certificateCacheManager.CreateTrustedRootCertificate(); certValidated = certificateManager.CreateTrustedRootCertificate();
if (TrustRootCertificate) if (TrustRootCertificate)
{ {
certificateCacheManager.TrustRootCertificate(ExceptionFunc); certificateManager.TrustRootCertificate(ExceptionFunc);
} }
} }
} }
...@@ -520,7 +522,7 @@ namespace Titanium.Web.Proxy ...@@ -520,7 +522,7 @@ namespace Titanium.Web.Proxy
ProxyEndPoints.Clear(); ProxyEndPoints.Clear();
certificateCacheManager?.StopClearIdleCertificates(); certificateManager?.StopClearIdleCertificates();
proxyRunning = false; proxyRunning = false;
} }
...@@ -648,7 +650,7 @@ namespace Titanium.Web.Proxy ...@@ -648,7 +650,7 @@ namespace Titanium.Web.Proxy
Stop(); Stop();
} }
certificateCacheManager?.Dispose(); certificateManager?.Dispose();
} }
/// <summary> /// <summary>
......
...@@ -115,7 +115,7 @@ namespace Titanium.Web.Proxy ...@@ -115,7 +115,7 @@ namespace Titanium.Web.Proxy
sslStream = new SslStream(clientStream, true); sslStream = new SslStream(clientStream, true);
var certificate = endPoint.GenericCertificate ?? certificateCacheManager.CreateCertificate(httpRemoteUri.Host, false); var certificate = endPoint.GenericCertificate ?? certificateManager.CreateCertificate(httpRemoteUri.Host, false);
//Successfully managed to authenticate the client using the fake certificate //Successfully managed to authenticate the client using the fake certificate
await sslStream.AuthenticateAsServerAsync(certificate, false, await sslStream.AuthenticateAsServerAsync(certificate, false,
...@@ -185,7 +185,7 @@ namespace Titanium.Web.Proxy ...@@ -185,7 +185,7 @@ namespace Titanium.Web.Proxy
var sslStream = new SslStream(clientStream, true); var sslStream = new SslStream(clientStream, true);
//implement in future once SNI supported by SSL stream, for now use the same certificate //implement in future once SNI supported by SSL stream, for now use the same certificate
var certificate = certificateCacheManager.CreateCertificate(endPoint.GenericCertificateName, false); var certificate = certificateManager.CreateCertificate(endPoint.GenericCertificateName, false);
try try
{ {
......
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