Skip to content

Commit

Permalink
1444-thread safe s_enclaveProviders
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Ashofteh committed Dec 28, 2021
1 parent f492b71 commit 106e80b
Showing 1 changed file with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,23 @@ private SqlColumnEncryptionEnclaveProvider GetEnclaveProvider(SqlConnectionAttes
{
if (!s_enclaveProviders.TryGetValue(attestationProtocol, out SqlColumnEncryptionEnclaveProvider sqlColumnEncryptionEnclaveProvider))
{
switch (attestationProtocol)
lock (_lock)
{
case SqlConnectionAttestationProtocol.AAS:
AzureAttestationEnclaveProvider azureAttestationEnclaveProvider = new AzureAttestationEnclaveProvider();
s_enclaveProviders[attestationProtocol] = azureAttestationEnclaveProvider;
sqlColumnEncryptionEnclaveProvider = s_enclaveProviders[attestationProtocol];
break;

case SqlConnectionAttestationProtocol.HGS:
HostGuardianServiceEnclaveProvider hostGuardianServiceEnclaveProvider = new HostGuardianServiceEnclaveProvider();
s_enclaveProviders[attestationProtocol] = hostGuardianServiceEnclaveProvider;
sqlColumnEncryptionEnclaveProvider = s_enclaveProviders[attestationProtocol];
break;
if (!s_enclaveProviders.TryGetValue(attestationProtocol, out sqlColumnEncryptionEnclaveProvider))
{
switch (attestationProtocol)
{
case SqlConnectionAttestationProtocol.AAS:
AzureAttestationEnclaveProvider azureAttestationEnclaveProvider = new AzureAttestationEnclaveProvider();
s_enclaveProviders[attestationProtocol] = azureAttestationEnclaveProvider;
sqlColumnEncryptionEnclaveProvider = s_enclaveProviders[attestationProtocol];
break;

case SqlConnectionAttestationProtocol.HGS:
HostGuardianServiceEnclaveProvider hostGuardianServiceEnclaveProvider = new HostGuardianServiceEnclaveProvider();
s_enclaveProviders[attestationProtocol] = hostGuardianServiceEnclaveProvider;
sqlColumnEncryptionEnclaveProvider = s_enclaveProviders[attestationProtocol];
break;

#if ENCLAVE_SIMULATOR
case SqlConnectionAttestationProtocol.SIM:
Expand All @@ -109,8 +113,10 @@ private SqlColumnEncryptionEnclaveProvider GetEnclaveProvider(SqlConnectionAttes
break;
#endif

default:
break;
default:
break;
}
}
}
}

Expand Down

0 comments on commit 106e80b

Please sign in to comment.