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
5c24d9cb
Commit
5c24d9cb
authored
Oct 31, 2018
by
Anton Ryzhov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding lock to CreateRootCertificate method
parent
f2b2ce52
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
39 deletions
+52
-39
CertificateManager.cs
src/Titanium.Web.Proxy/Network/CertificateManager.cs
+47
-38
DefaultCertificateDiskCache.cs
...Titanium.Web.Proxy/Network/DefaultCertificateDiskCache.cs
+5
-1
No files found.
src/Titanium.Web.Proxy/Network/CertificateManager.cs
View file @
5c24d9cb
...
...
@@ -48,6 +48,8 @@ namespace Titanium.Web.Proxy.Network
private
readonly
CancellationTokenSource
clearCertificatesTokenSource
;
private
readonly
object
rootCertCreationLock
;
private
ICertificateMaker
certEngine
;
private
CertificateEngine
engine
;
...
...
@@ -103,6 +105,8 @@ namespace Titanium.Web.Proxy.Network
clearCertificatesTokenSource
=
new
CancellationTokenSource
();
certificateCache
=
new
DefaultCertificateDiskCache
();
rootCertCreationLock
=
new
object
();
}
/// <summary>
...
...
@@ -514,6 +518,8 @@ namespace Titanium.Web.Proxy.Network
/// true if succeeded, else false.
/// </returns>
public
bool
CreateRootCertificate
(
bool
persistToFile
=
true
)
{
lock
(
rootCertCreationLock
)
{
if
(
persistToFile
&&
RootCertificate
==
null
)
{
...
...
@@ -529,7 +535,9 @@ namespace Titanium.Web.Proxy.Network
{
try
{
var
rootCert
=
certificateCache
.
LoadRootCertificate
(
PfxFilePath
,
PfxPassword
,
X509KeyStorageFlags
.
Exportable
);
var
rootCert
=
certificateCache
.
LoadRootCertificate
(
PfxFilePath
,
PfxPassword
,
X509KeyStorageFlags
.
Exportable
);
if
(
rootCert
!=
null
)
{
return
false
;
...
...
@@ -573,6 +581,7 @@ namespace Titanium.Web.Proxy.Network
return
RootCertificate
!=
null
;
}
}
/// <summary>
/// Loads root certificate from current executing assembly location with expected name rootCert.pfx.
...
...
@@ -600,7 +609,7 @@ namespace Titanium.Web.Proxy.Network
/// </param>
/// <param name="password">Set a password for the .pfx file.</param>
/// <param name="overwritePfXFile">
/// true : replace an existing .pfx file if password is incorect or if
/// true : replace an existing .pfx file if password is incor
r
ect or if
/// RootCertificate==null.
/// </param>
/// <param name="storageFlag"></param>
...
...
src/Titanium.Web.Proxy/Network/DefaultCertificateDiskCache.cs
View file @
5c24d9cb
...
...
@@ -43,10 +43,14 @@ namespace Titanium.Web.Proxy.Network
public
void
Clear
()
{
if
(
Directory
.
Exists
(
getCertificatePath
()))
try
{
Directory
.
Delete
(
getCertificatePath
(),
true
);
}
catch
(
DirectoryNotFoundException
)
{
// do nothing
}
certificatePath
=
null
;
}
...
...
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