Commit aab71848 authored by ilushka85's avatar ilushka85

cert manager save rootCertificate and load from local file

parent 722036e4
...@@ -5,6 +5,7 @@ using System.Threading.Tasks; ...@@ -5,6 +5,7 @@ using System.Threading.Tasks;
using System.Threading; using System.Threading;
using System.Linq; using System.Linq;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.IO;
namespace Titanium.Web.Proxy.Network namespace Titanium.Web.Proxy.Network
{ {
...@@ -42,9 +43,33 @@ namespace Titanium.Web.Proxy.Network ...@@ -42,9 +43,33 @@ namespace Titanium.Web.Proxy.Network
/// </summary> /// </summary>
/// <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"))
{
try
{
rootCertificate = new X509Certificate2("rootCert.pfx");
}
catch
{
}
}
if (rootCertificate == null)
{ {
rootCertificate = CreateCertificate(RootCertificateName, true); rootCertificate = CreateCertificate(RootCertificateName, true);
}
if (rootCertificate != null)
{
try
{
File.WriteAllBytes("rootCert.pfx", rootCertificate.Export(X509ContentType.Pkcs12));
}
catch
{
}
}
return rootCertificate != null; return rootCertificate != null;
} }
/// <summary> /// <summary>
......
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