Skip to content

Commit c1f5b65

Browse files
authored
[3.1.0] | Add new Attestation Protocol "None" (#1539)
1 parent c944713 commit c1f5b65

File tree

28 files changed

+263
-402
lines changed

28 files changed

+263
-402
lines changed

doc/snippets/Microsoft.Data.SqlClient/SqlConnection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ End Module
528528
|Application Intent<br /><br /> -or-<br /><br />ApplicationIntent|ReadWrite|Declares the application workload type when connecting to a server. Possible values are `ReadOnly` and `ReadWrite`. For example:<br /><br /> `ApplicationIntent=ReadOnly`<br /><br /> For more information about SqlClient support for Always On Availability Groups, see [SqlClient Support for High Availability, Disaster Recovery](/sql/connect/ado-net/sql/sqlclient-support-high-availability-disaster-recovery).|
529529
|Asynchronous Processing<br /><br /> -or-<br /><br /> Async|'false'|This property is obsolete and should not used.<br /><br /> When `true`, enables asynchronous operation support. Recognized values are `true`, `false`, `yes`, and `no`.<br /><br /> This property is ignored beginning in .NET Framework 4.5. For more information about SqlClient support for asynchronous programming, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).|
530530
|AttachDBFilename<br /><br /> -or-<br /><br /> Extended Properties<br /><br /> -or-<br /><br /> Initial File Name|N/A|The name of the primary database file, including the full path name of an attachable database. AttachDBFilename is only supported for primary data files with an .mdf extension.<br /><br /> If the value of the AttachDBFileName key is specified in the connection string, the database is attached and becomes the default database for the connection.<br /><br /> If this key is not specified and if the database was previously attached, the database will not be reattached. The previously attached database will be used as the default database for the connection.<br /><br /> If this key is specified together with the AttachDBFileName key, the value of this key will be used as the alias. However, if the name is already used in another attached database, the connection will fail.<br /><br /> The path may be absolute or relative by using the DataDirectory substitution string. If DataDirectory is used, the database file must exist within a subdirectory of the directory pointed to by the substitution string. **Note:** Remote server, HTTP, and UNC path names are not supported. <br /><br /> The database name must be specified with the keyword 'database' (or one of its aliases) as in the following:<br /><br /> <code>"AttachDbFileName=&#124;DataDirectory&#124;\data\YourDB.mdf;integrated security=true;database=YourDatabase"</code><br /><br /> An error will be generated if a log file exists in the same directory as the data file and the 'database' keyword is used when attaching the primary data file. In this case, remove the log file. Once the database is attached, a new log file will be automatically generated based on the physical path.|
531-
|Attestation Protocol|N/A|Gets or sets the value of Attestation Protocol.<br /><br />Valid values are:<br />`AAS`<br />`HGS`|
531+
|Attestation Protocol|N/A|Gets or sets the value of Attestation Protocol.<br /><br />Valid values are:<br />`AAS`<br />`HGS`<br />`None`|
532532
|Authentication|N/A|The authentication method used for [Connecting to SQL Database By Using Azure Active Directory Authentication](https://azure.microsoft.com/documentation/articles/sql-database-aad-authentication/#7-connect-to-your-database-by-using-azure-active-directory-identities).<br /><br /> Valid values are:<br /><br /> `Active Directory Integrated`, `Active Directory Interactive`, `Active Directory Password`, 'Active Directory Service Principal', 'Active Directory Device Code Flow', 'Active Directory Managed Identity', 'Active Directory MSI', 'Active Directory Default', `Sql Password`. Currently `Active Directory Integrated` and `Active Directory Interactive` modes of authentication are supported only for .NET Framework. |
533533
|Column Encryption Setting|N/A|Enables or disables [Always Encrypted](/sql/relational-databases/security/encryption/always-encrypted-database-engine?view=sql-server-2017) functionality for the connection.|
534534
|Command Timeout|30|The default wait time (in seconds) before terminating the attempt to execute a command and generating an error.<br /><br /> Valid values are greater than or equal to 0 and less than or equal to 2147483647.|

doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
<summary>Attestation portocol for Azure Attestation Service</summary>
1414
<value>1</value>
1515
</AAS>
16-
<SIM>
17-
<summary>Attestation protocol for Simulator</summary>
16+
<None>
17+
<summary>Attestation protocol for no attestation. Only compatible with Virtualization-based security (VBS) enclaves. An Enclave Attestation Url is not required when using this protocol.</summary>
1818
<value>2</value>
19-
</SIM>
19+
</None>
2020
<HGS>
2121
<summary>Attestation protocol for Host Guardian Service</summary>
2222
<value>3</value>

src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,8 @@ public enum SqlConnectionAttestationProtocol
391391
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/AAS/*' />
392392
AAS = 1,
393393

394-
#if ENCLAVE_SIMULATOR
395-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/SIM/*' />
396-
SIM = 2,
397-
#endif
394+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/None/*' />
395+
None = 2,
398396

399397
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/HGS/*' />
400398
HGS = 3

src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,9 @@
370370
<Compile Include="..\..\src\Microsoft\Data\SqlClient\VirtualSecureModeEnclaveProvider.cs">
371371
<Link>Microsoft\Data\SqlClient\VirtualSecureModeEnclaveProvider.cs</Link>
372372
</Compile>
373+
<Compile Include="..\..\src\Microsoft\Data\SqlClient\NoneAttestationEnclaveProvider.cs">
374+
<Link>Microsoft\Data\SqlClient\NoneAttestationEnclaveProvider.cs</Link>
375+
</Compile>
373376
<Compile Include="..\..\src\Microsoft\Data\SqlClient\VirtualSecureModeEnclaveProviderBase.cs">
374377
<Link>Microsoft\Data\SqlClient\VirtualSecureModeEnclaveProviderBase.cs</Link>
375378
</Compile>
@@ -391,9 +394,6 @@
391394
<Compile Include="Microsoft\Data\SqlClient\SqlConnectionFactory.AssemblyLoadContext.cs" />
392395
<Compile Include="Microsoft\Data\SqlClient\SqlDependencyUtils.AssemblyLoadContext.cs" />
393396
</ItemGroup>
394-
<ItemGroup Condition="'$(OSGroup)' != 'AnyOS' AND '$(TargetFramework)' != 'netstandard2.0' AND '$(BuildSimulator)' == 'true'">
395-
<Compile Include="Microsoft\Data\SqlClient\SimulatorEnclaveProvider.NetCoreApp.cs" />
396-
</ItemGroup>
397397
<ItemGroup Condition="'$(OSGroup)' != 'AnyOS'">
398398
<Compile Include="Microsoft\Data\SqlClient\Server\MetadataUtilsSmi.cs" />
399399
<Compile Include="Microsoft\Data\SqlClient\Server\SmiEventSink.cs" />

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionStringCommon.cs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,7 @@ internal static string ColumnEncryptionSettingToString(SqlConnectionColumnEncryp
306306
/// </summary>
307307
const string AttestationProtocolHGS = "HGS";
308308
const string AttestationProtocolAAS = "AAS";
309-
#if ENCLAVE_SIMULATOR
310-
const string AttestationProtocolSIM = "SIM";
311-
#endif
309+
const string AttestationProtocolNone = "None";
312310

313311
/// <summary>
314312
/// Convert a string value to the corresponding SqlConnectionAttestationProtocol
@@ -328,13 +326,11 @@ internal static bool TryConvertToAttestationProtocol(string value, out SqlConnec
328326
result = SqlConnectionAttestationProtocol.AAS;
329327
return true;
330328
}
331-
#if ENCLAVE_SIMULATOR
332-
else if (StringComparer.InvariantCultureIgnoreCase.Equals(value, AttestationProtocolSIM))
329+
else if (StringComparer.InvariantCultureIgnoreCase.Equals(value, AttestationProtocolNone))
333330
{
334-
result = SqlConnectionAttestationProtocol.SIM;
331+
result = SqlConnectionAttestationProtocol.None;
335332
return true;
336333
}
337-
#endif
338334
else
339335
{
340336
result = DbConnectionStringDefaults.AttestationProtocol;
@@ -344,18 +340,11 @@ internal static bool TryConvertToAttestationProtocol(string value, out SqlConnec
344340

345341
internal static bool IsValidAttestationProtocol(SqlConnectionAttestationProtocol value)
346342
{
347-
#if ENCLAVE_SIMULATOR
348343
Debug.Assert(Enum.GetNames(typeof(SqlConnectionAttestationProtocol)).Length == 4, "SqlConnectionAttestationProtocol enum has changed, update needed");
349344
return value == SqlConnectionAttestationProtocol.NotSpecified
350345
|| value == SqlConnectionAttestationProtocol.HGS
351346
|| value == SqlConnectionAttestationProtocol.AAS
352-
|| value == SqlConnectionAttestationProtocol.SIM;
353-
#else
354-
Debug.Assert(Enum.GetNames(typeof(SqlConnectionAttestationProtocol)).Length == 3, "SqlConnectionAttestationProtocol enum has changed, update needed");
355-
return value == SqlConnectionAttestationProtocol.NotSpecified
356-
|| value == SqlConnectionAttestationProtocol.HGS
357-
|| value == SqlConnectionAttestationProtocol.AAS;
358-
#endif
347+
|| value == SqlConnectionAttestationProtocol.None;
359348
}
360349

361350
internal static string AttestationProtocolToString(SqlConnectionAttestationProtocol value)
@@ -368,10 +357,8 @@ internal static string AttestationProtocolToString(SqlConnectionAttestationProto
368357
return AttestationProtocolHGS;
369358
case SqlConnectionAttestationProtocol.AAS:
370359
return AttestationProtocolAAS;
371-
#if ENCLAVE_SIMULATOR
372-
case SqlConnectionAttestationProtocol.SIM:
373-
return AttestationProtocolSIM;
374-
#endif
360+
case SqlConnectionAttestationProtocol.None:
361+
return AttestationProtocolNone;
375362
default:
376363
return null;
377364
}

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SimulatorEnclaveProvider.NetCoreApp.cs

Lines changed: 0 additions & 115 deletions
This file was deleted.

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,9 @@ internal bool IsColumnEncryptionEnabled
197197
}
198198
}
199199

200-
internal bool ShouldUseEnclaveBasedWorkflow
201-
{
202-
get { return !string.IsNullOrWhiteSpace(_activeConnection.EnclaveAttestationUrl) && IsColumnEncryptionEnabled; }
203-
}
200+
internal bool ShouldUseEnclaveBasedWorkflow =>
201+
(!string.IsNullOrWhiteSpace(_activeConnection.EnclaveAttestationUrl) || Connection.AttestationProtocol == SqlConnectionAttestationProtocol.None) &&
202+
IsColumnEncryptionEnabled;
204203

205204
/// <summary>
206205
/// Per-command custom providers. It can be provided by the user and can be set more than once.
@@ -4189,7 +4188,7 @@ private void ReadDescribeEncryptionParameterResults(SqlDataReader ds, ReadOnlyDi
41894188

41904189
if (isRequestedByEnclave)
41914190
{
4192-
if (string.IsNullOrWhiteSpace(this.Connection.EnclaveAttestationUrl))
4191+
if (string.IsNullOrWhiteSpace(this.Connection.EnclaveAttestationUrl) && Connection.AttestationProtocol != SqlConnectionAttestationProtocol.None)
41934192
{
41944193
throw SQL.NoAttestationUrlSpecifiedForEnclaveBasedQuerySpDescribe(this._activeConnection.Parser.EnclaveType);
41954194
}
@@ -4619,8 +4618,11 @@ private void GenerateEnclavePackage()
46194618
return;
46204619
}
46214620

4622-
if (string.IsNullOrWhiteSpace(this._activeConnection.EnclaveAttestationUrl))
4621+
if (string.IsNullOrWhiteSpace(this._activeConnection.EnclaveAttestationUrl) &&
4622+
Connection.AttestationProtocol != SqlConnectionAttestationProtocol.None)
4623+
{
46234624
throw SQL.NoAttestationUrlSpecifiedForEnclaveBasedQueryGeneratingEnclavePackage(this._activeConnection.Parser.EnclaveType);
4625+
}
46244626

46254627
string enclaveType = this._activeConnection.Parser.EnclaveType;
46264628
if (string.IsNullOrWhiteSpace(enclaveType))

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsEnums.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,10 +1070,8 @@ public enum SqlConnectionAttestationProtocol
10701070
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/AAS/*' />
10711071
AAS = 1,
10721072

1073-
#if ENCLAVE_SIMULATOR
1074-
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/SIM/*' />
1075-
SIM = 2,
1076-
#endif
1073+
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/None/*' />
1074+
None = 2,
10771075

10781076
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConnectionAttestationProtocol.xml' path='docs/members[@name="SqlConnectionAttestationProtocol"]/HGS/*' />
10791077
HGS = 3

0 commit comments

Comments
 (0)