-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add | Adding Net6 support and dropping netcoreapp3.1 #1704
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<AssemblyName>Microsoft.Data.SqlClient</AssemblyName> | ||
<TargetFrameworks>netcoreapp3.1;netstandard2.0;netstandard2.1</TargetFrameworks> | ||
<TargetFrameworks>net6.0;netstandard2.0;netstandard2.1</TargetFrameworks> | ||
<TargetFrameworks Condition="$(ReferenceType)=='NetStandard' AND $(TargetNetStandardVersion)=='netstandard2.1'">netstandard2.1</TargetFrameworks> | ||
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(OSGroup)' == 'AnyOS'">Microsoft.Data.SqlClient is not supported on this platform.</GeneratePlatformNotSupportedAssemblyMessage> | ||
<OSGroup Condition="'$(OSGroup)' == ''">$(OS)</OSGroup> | ||
<TargetsWindows Condition="'$(OSGroup)'=='Windows_NT'">true</TargetsWindows> | ||
<TargetsUnix Condition="'$(OSGroup)'=='Unix'">true</TargetsUnix> | ||
<!-- Allow explicit addition of the Compile files instead of all project files to be included by Default --> | ||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems> | ||
<TargetGroup Condition="$(TargetFramework.StartsWith('netcoreapp'))">netcoreapp</TargetGroup> | ||
<TargetGroup Condition="$(TargetFramework.StartsWith('netstandard'))">netstandard</TargetGroup> | ||
<TargetGroup Condition="'$([MSBuild]::GetTargetFrameworkIdentifier($(TargetFramework)))'=='.NETCoreApp'">netcoreapp</TargetGroup> | ||
<TargetGroup Condition="'$([MSBuild]::GetTargetFrameworkIdentifier($(TargetFramework)))'=='.NETStandard'">netstandard</TargetGroup> | ||
<Configurations>Debug;Release;</Configurations> | ||
<Platforms>AnyCPU;x64;x86</Platforms> | ||
<IntermediateOutputPath>$(ObjFolder)$(Configuration).$(Platform)\$(AssemblyName)\netcore\</IntermediateOutputPath> | ||
|
@@ -19,12 +19,6 @@ | |
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<Product>Core $(BaseProduct)</Product> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(TargetGroup)' == 'netcoreapp'"> | ||
<DefineConstants>$(DefineConstants);NETCOREAPP;</DefineConstants> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(TargetGroup)' == 'netstandard'"> | ||
<DefineConstants>$(DefineConstants);NETSTANDARD;</DefineConstants> | ||
</PropertyGroup> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using bult-in constants instead of creating new ones. |
||
<PropertyGroup> | ||
<DebugType>portable</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,7 +79,15 @@ public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string e | |
|
||
// Parse the path and get the X509 cert | ||
X509Certificate2 certificate = GetCertificateByPath(masterKeyPath, isSystemOp: true); | ||
int keySizeInBytes = certificate.PublicKey.Key.KeySize / 8; | ||
|
||
RSA RSAPublicKey = certificate.GetRSAPublicKey(); | ||
int keySizeInBytes; | ||
#if NETCOREAPP || NETSTANDARD2_1 | ||
DSA DSAPublicKey = certificate.GetDSAPublicKey(); | ||
keySizeInBytes = RSAPublicKey is not null ? RSAPublicKey.KeySize / 8 : DSAPublicKey.KeySize / 8; | ||
#else | ||
keySizeInBytes= RSAPublicKey.KeySize / 8; | ||
#endif | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PublicKey.Key is obsolete. Currently GetRSAPublicKey is being used but using DSAKey might be added in future. |
||
// Validate and decrypt the EncryptedColumnEncryptionKey | ||
// Format is | ||
|
@@ -172,7 +180,15 @@ public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string e | |
|
||
// Parse the certificate path and get the X509 cert | ||
X509Certificate2 certificate = GetCertificateByPath(masterKeyPath, isSystemOp: false); | ||
int keySizeInBytes = certificate.PublicKey.Key.KeySize / 8; | ||
|
||
RSA RSAPublicKey = certificate.GetRSAPublicKey(); | ||
int keySizeInBytes; | ||
#if NETCOREAPP || NETSTANDARD2_1 | ||
DSA DSAPublicKey = certificate.GetDSAPublicKey(); | ||
keySizeInBytes = RSAPublicKey is not null ? RSAPublicKey.KeySize / 8 : DSAPublicKey.KeySize / 8; | ||
#else | ||
keySizeInBytes= RSAPublicKey.KeySize / 8; | ||
#endif | ||
|
||
// Construct the encryptedColumnEncryptionKey | ||
// Format is | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.NET 5.0 added new attributes, SupportedOSPlatformAttribute and UnsupportedOSPlatformAttribute, to annotate platform-specific APIs. Both attributes can be instantiated with or without version numbers as part of the platform name. They can also be applied multiple times with different platforms. However, SqlClient currently is following a different structure for adding related files for different platforms.