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