Commit fe9c86a9 authored by mohammadlachgar's avatar mohammadlachgar

Fix & Add property TrustRootCertificateAsAdministrator

parent af0c17cf
...@@ -23,7 +23,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -23,7 +23,7 @@ namespace Titanium.Web.Proxy.Examples.Wpf
private int lastSessionNumber; private int lastSessionNumber;
public ObservableCollection<SessionListItem> Sessions { get; } = new ObservableCollection<SessionListItem>(); public ObservableCollection<SessionListItem> Sessions { get; } = new ObservableCollection<SessionListItem>();
public SessionListItem SelectedSession public SessionListItem SelectedSession
{ {
...@@ -79,6 +79,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -79,6 +79,9 @@ namespace Titanium.Web.Proxy.Examples.Wpf
//Trust Root Certificate //Trust Root Certificate
proxyServer.TrustRootCertificate = true; proxyServer.TrustRootCertificate = true;
proxyServer.TrustRootCertificateAsAdministrator = true;
proxyServer.ForwardToUpstreamGateway = true;
////if you need Load or Create Certificate now. ////// "true" if you need Enable===> Trust the RootCertificate used by this proxy server ////if you need Load or Create Certificate now. ////// "true" if you need Enable===> Trust the RootCertificate used by this proxy server
//proxyServer.EnsureRootCertificate(true); //proxyServer.EnsureRootCertificate(true);
...@@ -89,9 +92,6 @@ namespace Titanium.Web.Proxy.Examples.Wpf ...@@ -89,9 +92,6 @@ namespace Titanium.Web.Proxy.Examples.Wpf
////note : load now (if existed) ////note : load now (if existed)
//proxyServer.CertificateManager.LoadRootCertificate(@"C:\NameFolder\rootCert.pfx", "PfxPassword"); //proxyServer.CertificateManager.LoadRootCertificate(@"C:\NameFolder\rootCert.pfx", "PfxPassword");
proxyServer.CertificateManager.TrustRootCertificateAsAdministrator();
proxyServer.ForwardToUpstreamGateway = true;
var explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000, true) var explicitEndPoint = new ExplicitProxyEndPoint(IPAddress.Any, 8000, true)
{ {
ExcludedHttpsHostNameRegex = new[] { "ssllabs.com" }, ExcludedHttpsHostNameRegex = new[] { "ssllabs.com" },
......
...@@ -119,6 +119,13 @@ namespace Titanium.Web.Proxy ...@@ -119,6 +119,13 @@ namespace Titanium.Web.Proxy
set => CertificateManager.trustRootCertificate = value; set => CertificateManager.trustRootCertificate = value;
} }
/// <summary>
/// Needs elevated permission. Works only on Windows.
/// <para>Puts the certificate to the local machine's certificate store.</para>
/// <para>Certutil.exe is a command-line program that is installed as part of Certificate Services</para>
/// </summary>
public bool TrustRootCertificateAsAdministrator { get; set; } = false;
/// <summary> /// <summary>
/// Save all fake certificates in folder "crts"(will be created in proxy dll directory) /// Save all fake certificates in folder "crts"(will be created in proxy dll directory)
/// <para>for can load the certificate and not make new certificate every time </para> /// <para>for can load the certificate and not make new certificate every time </para>
...@@ -755,6 +762,11 @@ namespace Titanium.Web.Proxy ...@@ -755,6 +762,11 @@ namespace Titanium.Web.Proxy
{ {
CertificateManager.TrustRootCertificate(); CertificateManager.TrustRootCertificate();
} }
if (TrustRootCertificateAsAdministrator)
{
CertificateManager.TrustRootCertificateAsAdministrator();
}
} }
} }
......
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