Commit b5c96465 authored by Honfika's avatar Honfika

Allow to remove the machine root certificate

parent eb66c695
...@@ -276,6 +276,46 @@ namespace Titanium.Web.Proxy.Network ...@@ -276,6 +276,46 @@ namespace Titanium.Web.Proxy.Network
RemoveTrustedRootCertificates(StoreLocation.LocalMachine); RemoveTrustedRootCertificates(StoreLocation.LocalMachine);
} }
/// <summary>
/// Removes the trusted certificates from the local machine's certificate store.
/// Needs elevated permission. Works only on Windows.
/// </summary>
/// <returns></returns>
public bool RemoveTrustedRootCertificatesAsAdministrator()
{
if (RunTime.IsRunningOnMono)
{
return false;
}
var info = new ProcessStartInfo
{
FileName = "certutil.exe",
Arguments = "-delstore Root \"" + RootCertificateName + "\"",
CreateNoWindow = true,
UseShellExecute = true,
Verb = "runas",
ErrorDialog = false,
};
try
{
var process = Process.Start(info);
if (process == null)
{
return false;
}
process.WaitForExit();
}
catch
{
return false;
}
return true;
}
/// <summary> /// <summary>
/// Determines whether the root certificate is trusted. /// Determines whether the root certificate is trusted.
/// </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