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
a6f402f7
Commit
a6f402f7
authored
Mar 12, 2018
by
justcoding121
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent certificates getting piled up in user\personal store with WinCert Maker
parent
5d5b32e9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
CertificateManager.cs
Titanium.Web.Proxy/Network/CertificateManager.cs
+20
-14
No files found.
Titanium.Web.Proxy/Network/CertificateManager.cs
View file @
a6f402f7
...
@@ -274,7 +274,15 @@ namespace Titanium.Web.Proxy.Network
...
@@ -274,7 +274,15 @@ namespace Titanium.Web.Proxy.Network
CreateRootCertificate
();
CreateRootCertificate
();
}
}
return
certEngine
.
MakeCertificate
(
certificateName
,
isRootCertificate
,
RootCertificate
);
var
certificate
=
certEngine
.
MakeCertificate
(
certificateName
,
isRootCertificate
,
RootCertificate
);
if
(
CertificateEngine
==
CertificateEngine
.
DefaultWindows
)
{
//prevent certificates getting piled up in User\Personal store
Task
.
Run
(()
=>
UninstallCertificate
(
StoreName
.
My
,
StoreLocation
.
CurrentUser
,
certificate
));
}
return
certificate
;
}
}
/// <summary>
/// <summary>
...
@@ -282,7 +290,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -282,7 +290,7 @@ namespace Titanium.Web.Proxy.Network
/// </summary>
/// </summary>
/// <param name="storeLocation"></param>
/// <param name="storeLocation"></param>
/// <returns></returns>
/// <returns></returns>
private
void
TrustRoot
Certificate
(
StoreName
storeName
,
StoreLocation
storeLocation
)
private
void
Install
Certificate
(
StoreName
storeName
,
StoreLocation
storeLocation
)
{
{
if
(
RootCertificate
==
null
)
if
(
RootCertificate
==
null
)
{
{
...
@@ -320,7 +328,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -320,7 +328,7 @@ namespace Titanium.Web.Proxy.Network
/// </summary>
/// </summary>
/// <param name="storeLocation"></param>
/// <param name="storeLocation"></param>
/// <returns></returns>
/// <returns></returns>
private
void
RemoveTrustedRootCertificate
(
StoreName
storeName
,
StoreLocation
storeLocation
)
private
void
UninstallCertificate
(
StoreName
storeName
,
StoreLocation
storeLocation
,
X509Certificate2
certificate
)
{
{
if
(
RootCertificate
==
null
)
if
(
RootCertificate
==
null
)
{
{
...
@@ -337,7 +345,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -337,7 +345,7 @@ namespace Titanium.Web.Proxy.Network
{
{
x509Store
.
Open
(
OpenFlags
.
ReadWrite
);
x509Store
.
Open
(
OpenFlags
.
ReadWrite
);
x509Store
.
Remove
(
RootC
ertificate
);
x509Store
.
Remove
(
c
ertificate
);
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
...
@@ -624,13 +632,13 @@ namespace Titanium.Web.Proxy.Network
...
@@ -624,13 +632,13 @@ namespace Titanium.Web.Proxy.Network
public
void
TrustRootCertificate
()
public
void
TrustRootCertificate
()
{
{
//current user
//current user
TrustRoot
Certificate
(
StoreName
.
My
,
StoreLocation
.
CurrentUser
);
Install
Certificate
(
StoreName
.
My
,
StoreLocation
.
CurrentUser
);
//current system
//current system
TrustRoot
Certificate
(
StoreName
.
My
,
StoreLocation
.
LocalMachine
);
Install
Certificate
(
StoreName
.
My
,
StoreLocation
.
LocalMachine
);
//this adds to both currentUser\Root & currentMachine\Root
//this adds to both currentUser\Root & currentMachine\Root
TrustRoot
Certificate
(
StoreName
.
Root
,
StoreLocation
.
LocalMachine
);
Install
Certificate
(
StoreName
.
Root
,
StoreLocation
.
LocalMachine
);
}
}
/// <summary>
/// <summary>
...
@@ -649,7 +657,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -649,7 +657,7 @@ namespace Titanium.Web.Proxy.Network
File
.
WriteAllBytes
(
pfxFileName
,
RootCertificate
.
Export
(
X509ContentType
.
Pkcs12
,
PfxPassword
));
File
.
WriteAllBytes
(
pfxFileName
,
RootCertificate
.
Export
(
X509ContentType
.
Pkcs12
,
PfxPassword
));
//currentUser\Personal
//currentUser\Personal
TrustRoot
Certificate
(
StoreName
.
My
,
StoreLocation
.
CurrentUser
);
Install
Certificate
(
StoreName
.
My
,
StoreLocation
.
CurrentUser
);
//currentUser\Root, currentMachine\Personal & currentMachine\Root
//currentUser\Root, currentMachine\Personal & currentMachine\Root
var
info
=
new
ProcessStartInfo
()
var
info
=
new
ProcessStartInfo
()
...
@@ -689,13 +697,13 @@ namespace Titanium.Web.Proxy.Network
...
@@ -689,13 +697,13 @@ namespace Titanium.Web.Proxy.Network
public
void
RemoveTrustedRootCertificate
()
public
void
RemoveTrustedRootCertificate
()
{
{
//current user
//current user
RemoveTrustedRootCertificate
(
StoreName
.
My
,
StoreLocation
.
CurrentUser
);
UninstallCertificate
(
StoreName
.
My
,
StoreLocation
.
CurrentUser
,
RootCertificate
);
//current system
//current system
RemoveTrustedRootCertificate
(
StoreName
.
My
,
StoreLocation
.
LocalMachin
e
);
UninstallCertificate
(
StoreName
.
My
,
StoreLocation
.
LocalMachine
,
RootCertificat
e
);
//this removes from both currentUser\Root & currentMachine\Root
//this removes from both currentUser\Root & currentMachine\Root
RemoveTrustedRootCertificate
(
StoreName
.
Root
,
StoreLocation
.
LocalMachin
e
);
UninstallCertificate
(
StoreName
.
Root
,
StoreLocation
.
LocalMachine
,
RootCertificat
e
);
}
}
/// <summary>
/// <summary>
...
@@ -711,7 +719,7 @@ namespace Titanium.Web.Proxy.Network
...
@@ -711,7 +719,7 @@ namespace Titanium.Web.Proxy.Network
}
}
//currentUser\Personal
//currentUser\Personal
RemoveTrustedRootCertificate
(
StoreName
.
My
,
StoreLocation
.
CurrentUser
);
UninstallCertificate
(
StoreName
.
My
,
StoreLocation
.
CurrentUser
,
RootCertificate
);
var
infos
=
new
List
<
ProcessStartInfo
>()
var
infos
=
new
List
<
ProcessStartInfo
>()
{
{
...
@@ -776,8 +784,6 @@ namespace Titanium.Web.Proxy.Network
...
@@ -776,8 +784,6 @@ namespace Titanium.Web.Proxy.Network
return
FindRootCertificate
(
StoreLocation
.
LocalMachine
);
return
FindRootCertificate
(
StoreLocation
.
LocalMachine
);
}
}
/// <summary>
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
/// </summary>
...
...
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