Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Titanium-Web-Proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Titanium-Web-Proxy
Commits
64c32e30
Commit
64c32e30
authored
May 15, 2017
by
Honfika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to remove the root certificates from windows certmgr
parent
cfdcaee9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
ProxyTestController.cs
.../Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
+3
-0
CertificateManager.cs
Titanium.Web.Proxy/Network/CertificateManager.cs
+52
-0
No files found.
Examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs
View file @
64c32e30
...
...
@@ -98,6 +98,9 @@ namespace Titanium.Web.Proxy.Examples.Basic
proxyServer
.
ClientCertificateSelectionCallback
-=
OnCertificateSelection
;
proxyServer
.
Stop
();
//remove the generated certificates
//proxyServer.CertificateManager.RemoveTrustedRootCertificates();
}
//intecept & cancel redirect or update requests
...
...
Titanium.Web.Proxy/Network/CertificateManager.cs
View file @
64c32e30
...
...
@@ -217,6 +217,18 @@ namespace Titanium.Web.Proxy.Network
TrustRootCertificate
(
StoreLocation
.
LocalMachine
);
}
/// <summary>
/// Removes the trusted certificates.
/// </summary>
public
void
RemoveTrustedRootCertificates
()
{
//current user
RemoveTrustedRootCertificates
(
StoreLocation
.
CurrentUser
);
//current system
RemoveTrustedRootCertificates
(
StoreLocation
.
LocalMachine
);
}
/// <summary>
/// Create an SSL certificate
/// </summary>
...
...
@@ -339,6 +351,46 @@ namespace Titanium.Web.Proxy.Network
}
}
/// <summary>
/// Remove the Root Certificate trust
/// </summary>
/// <param name="storeLocation"></param>
/// <returns></returns>
internal
void
RemoveTrustedRootCertificates
(
StoreLocation
storeLocation
)
{
if
(
RootCertificate
==
null
)
{
exceptionFunc
(
new
Exception
(
"Could not set root certificate"
+
" as system proxy since it is null or empty."
));
return
;
}
X509Store
x509RootStore
=
new
X509Store
(
StoreName
.
Root
,
storeLocation
);
var
x509PersonalStore
=
new
X509Store
(
StoreName
.
My
,
storeLocation
);
try
{
x509RootStore
.
Open
(
OpenFlags
.
ReadWrite
);
x509PersonalStore
.
Open
(
OpenFlags
.
ReadWrite
);
x509RootStore
.
Remove
(
RootCertificate
);
x509PersonalStore
.
Remove
(
RootCertificate
);
}
catch
(
Exception
e
)
{
exceptionFunc
(
new
Exception
(
"Failed to make system trust root certificate "
+
$" for
{
storeLocation
}
store location. You may need admin rights."
,
e
));
}
finally
{
x509RootStore
.
Close
();
x509PersonalStore
.
Close
();
}
}
public
void
Dispose
()
{
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment