Commit e910ff08 authored by ilushka85's avatar ilushka85

Change Fiddler Name to Titanium + Fix innovcation errors from resaving root cert as not exportable

parent fef05f52
...@@ -171,7 +171,7 @@ namespace Titanium.Web.Proxy.Network ...@@ -171,7 +171,7 @@ namespace Titanium.Web.Proxy.Network
this.typeX509Enrollment.InvokeMember("InitializeFromRequest", BindingFlags.InvokeMethod, null, obj15, subject); this.typeX509Enrollment.InvokeMember("InitializeFromRequest", BindingFlags.InvokeMethod, null, obj15, subject);
if (IsRoot) if (IsRoot)
{ {
subject[0] = "DO_NOT_TRUST_FiddlerRoot-CE"; subject[0] = "DO_NOT_TRUST_TitaniumProxy-CE";
this.typeX509Enrollment.InvokeMember("CertificateFriendlyName", BindingFlags.PutDispProperty, null, obj15, subject); this.typeX509Enrollment.InvokeMember("CertificateFriendlyName", BindingFlags.PutDispProperty, null, obj15, subject);
} }
subject[0] = 0; subject[0] = 0;
......
...@@ -6,6 +6,7 @@ using System.Threading; ...@@ -6,6 +6,7 @@ using System.Threading;
using System.Linq; using System.Linq;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.IO; using System.IO;
using System.Diagnostics;
namespace Titanium.Web.Proxy.Network namespace Titanium.Web.Proxy.Network
{ {
...@@ -44,21 +45,23 @@ namespace Titanium.Web.Proxy.Network ...@@ -44,21 +45,23 @@ namespace Titanium.Web.Proxy.Network
/// <returns>true if succeeded, else false</returns> /// <returns>true if succeeded, else false</returns>
internal bool CreateTrustedRootCertificate() internal bool CreateTrustedRootCertificate()
{ {
if(File.Exists("rootCert.pfx")) if (File.Exists("rootCert.pfx"))
{ {
try try
{ {
rootCertificate = new X509Certificate2("rootCert.pfx"); rootCertificate = new X509Certificate2("rootCert.pfx", string.Empty, X509KeyStorageFlags.Exportable);
if (rootCertificate != null)
{
return true;
}
} }
catch catch
{ {
} }
} }
if (rootCertificate == null)
{
rootCertificate = CreateCertificate(RootCertificateName, true); rootCertificate = CreateCertificate(RootCertificateName, true);
}
if (rootCertificate != null) if (rootCertificate != null)
{ {
try try
...@@ -94,14 +97,30 @@ namespace Titanium.Web.Proxy.Network ...@@ -94,14 +97,30 @@ namespace Titanium.Web.Proxy.Network
{ {
} }
X509Certificate2 certificate = null;
X509Certificate2 certificate = certEngine.CreateCert(certificateName, isRootCertificate,rootCertificate); lock (string.Intern(certificateName))
{
if (certificateCache.ContainsKey(certificateName) == false)
{
Debug.WriteLine(certificateName);
certificate = certEngine.CreateCert(certificateName, isRootCertificate, rootCertificate);
if (certificate != null && !certificateCache.ContainsKey(certificateName)) if (certificate != null && !certificateCache.ContainsKey(certificateName))
{ {
certificateCache.Add(certificateName, new CachedCertificate() { Certificate = certificate }); certificateCache.Add(certificateName, new CachedCertificate() { Certificate = certificate });
} }
}
else
{
if (certificateCache.ContainsKey(certificateName))
{
var cached = certificateCache[certificateName];
cached.LastAccess = DateTime.Now;
return cached.Certificate;
}
}
}
return certificate; return certificate;
......
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