Skip to content

Commit

Permalink
Enable ExtendedProtectionPolicy in generic System.Net.Security build (#…
Browse files Browse the repository at this point in the history
…88871)

* Enable ExtendedProtectionPolicy in generic System.Net.Security build (used on browser)

* Update tests
  • Loading branch information
filipnavara authored Jul 17, 2023
1 parent 8d3b757 commit 15e9370
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/libraries/System.Net.Security/src/ExcludeApiList.PNSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy
System.Security.Authentication.ExtendedProtection.ServiceNameCollection
15 changes: 9 additions & 6 deletions src/libraries/System.Net.Security/src/System.Net.Security.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PropertyGroup>
<TargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetPlatformIdentifier)' == ''">SR.SystemNetSecurity_PlatformNotSupported</GeneratePlatformNotSupportedAssemblyMessage>
<ApiExclusionListPath Condition="'$(TargetPlatformIdentifier)' == ''">ExcludeApiList.PNSE.txt</ApiExclusionListPath>
<DefineConstants Condition="'$(TargetPlatformIdentifier)' == 'windows'">$(DefineConstants);TARGET_WINDOWS</DefineConstants>
<DefineConstants Condition="'$(TargetPlatformIdentifier)' == 'android'">$(DefineConstants);TARGET_ANDROID</DefineConstants>
<UseAndroidCrypto Condition="'$(TargetPlatformIdentifier)' == 'android'">true</UseAndroidCrypto>
Expand All @@ -18,6 +19,14 @@
<GenAPIExcludeApiList>ReferenceAssemblyExclusions.txt</GenAPIExcludeApiList>
</PropertyGroup>
<Import Project="$(CommonPath)System\Security\Cryptography\Asn1Reader\System.Security.Cryptography.Asn1Reader.Shared.projitems" Condition="'$(UseManagedNtlm)' == 'true'" />
<ItemGroup>
<Compile Include="System\Security\Authentication\ExtendedProtection\ExtendedProtectionPolicy.cs" />
<Compile Include="System\Security\Authentication\ExtendedProtection\ServiceNameCollection.cs" />
<Compile Include="$(CommonPath)System\Obsoletions.cs"
Link="Common\System\Obsoletions.cs" />
<Compile Include="$(CommonPath)System\Net\UriScheme.cs"
Link="Common\System\Net\UriScheme.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != ''">
<Compile Include="System\Net\CertificateValidationPal.cs" />
<Compile Include="System\Net\SslStreamContext.cs" />
Expand Down Expand Up @@ -53,10 +62,8 @@
<Compile Include="System\Net\NTAuthentication.cs" />
<Compile Include="System\Net\StreamFramer.cs" />
<Compile Include="System\Net\Security\NegotiateStream.cs" />
<Compile Include="System\Security\Authentication\ExtendedProtection\ExtendedProtectionPolicy.cs" />
<Compile Include="System\Security\Authentication\ExtendedProtection\PolicyEnforcement.cs" />
<Compile Include="System\Security\Authentication\ExtendedProtection\ProtectionScenario.cs" />
<Compile Include="System\Security\Authentication\ExtendedProtection\ServiceNameCollection.cs" />
<!-- IP parser -->
<Compile Include="$(CommonPath)System\Net\IPv4AddressHelper.Common.cs"
Link="System\Net\IPv4AddressHelper.Common.cs" />
Expand Down Expand Up @@ -87,8 +94,6 @@
Link="Common\System\Net\ExceptionCheck.cs" />
<Compile Include="$(CommonPath)System\Net\SecurityProtocol.cs"
Link="Common\System\Net\SecurityProtocol.cs" />
<Compile Include="$(CommonPath)System\Net\UriScheme.cs"
Link="Common\System\Net\UriScheme.cs" />
<!-- Common -->
<Compile Include="$(CommonPath)System\NotImplemented.cs"
Link="Common\System\NotImplemented.cs" />
Expand All @@ -106,8 +111,6 @@
Condition="'$(UseManagedNtlm)' != 'true'" />
<Compile Include="$(CommonPath)System\HexConverter.cs"
Link="Common\System\HexConverter.cs" />
<Compile Include="$(CommonPath)System\Obsoletions.cs"
Link="Common\System\Obsoletions.cs" />
<Compile Include="$(CommonPath)Interop\Windows\SChannel\Interop.SECURITY_STATUS.cs"
Link="Common\Interop\Windows\SChannel\Interop.SECURITY_STATUS.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static bool OSSupportsExtendedProtection
get
{
// .NET Core is supported only on Win7+ where ExtendedProtection is supported.
return true;
return OperatingSystem.IsWindows();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,19 @@ public void Constructor_PolicyEnforcement_MembersAreSet()
}

[Fact]
public void ExtendedProtectionPolicy_OSSupportsExtendedProtection()
[PlatformSpecific(TestPlatforms.Windows)]
public void ExtendedProtectionPolicy_OSSupportsExtendedProtection_Windows()
{
Assert.True(ExtendedProtectionPolicy.OSSupportsExtendedProtection);
}

[Fact]
[PlatformSpecific(TestPlatforms.AnyUnix)]
public void ExtendedProtectionPolicy_OSSupportsExtendedProtection_NonWindows()
{
Assert.False(ExtendedProtectionPolicy.OSSupportsExtendedProtection);
}

[Fact]
public void ExtendedProtectionPolicy_Properties()
{
Expand Down

0 comments on commit 15e9370

Please sign in to comment.