Commit 2f2a3b2f authored by ilushka85's avatar ilushka85

reduce area of which semaphore is locked

parent 204c4da6
......@@ -108,9 +108,7 @@ namespace Titanium.Web.Proxy.Network
}
await semaphoreLock.WaitAsync();
try
{
X509Certificate2 certificate = null;
store.Open(OpenFlags.ReadWrite);
......@@ -133,7 +131,16 @@ namespace Titanium.Web.Proxy.Network
string[] args = new[] {
GetCertificateCreateArgs(store, certificateName) };
await semaphoreLock.WaitAsync();
try
{
await CreateCertificate(args);
}
finally
{
semaphoreLock.Release();
}
certificates = FindCertificates(store, certificateSubject);
//remove it from store
......@@ -156,11 +163,7 @@ namespace Titanium.Web.Proxy.Network
}
return certificate;
}
finally
{
semaphoreLock.Release();
}
}
/// <summary>
......@@ -301,7 +304,8 @@ namespace Titanium.Web.Proxy.Network
foreach (var cache in outdated)
certificateCache.Remove(cache.Key);
}
finally {
finally
{
semaphoreLock.Release();
}
......
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