Change TFM to netcoreapp2.0

This commit is contained in:
Pranav K 2017-05-04 15:13:46 -07:00
parent 525ca80d4f
commit 6986ab3a0f
6 changed files with 4 additions and 51 deletions

View File

@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.Antiforgery.Internal
private static string ComputeCookieName(string applicationId)
{
using (var sha256 = CryptographyAlgorithms.CreateSHA256())
using (var sha256 = SHA256.Create())
{
var hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(applicationId));
var subHash = hash.Take(8).ToArray();

View File

@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Antiforgery.Internal
{
if (_sha256 == null)
{
_sha256 = CryptographyAlgorithms.CreateSHA256();
_sha256 = SHA256.Create();
}
return _sha256;

View File

@ -1,40 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Security.Cryptography;
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public static class CryptographyAlgorithms
{
#if NETSTANDARD1_3
public static SHA256 CreateSHA256()
{
var sha256 = SHA256.Create();
return sha256;
}
#elif NET46
public static SHA256 CreateSHA256()
{
SHA256 sha256;
try
{
sha256 = SHA256.Create();
}
// SHA256.Create is documented to throw this exception on FIPS compliant machines.
// See: https://msdn.microsoft.com/en-us/library/z08hz7ad%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
catch (System.Reflection.TargetInvocationException)
{
// Fallback to a FIPS compliant SHA256 algorithm.
sha256 = new SHA256CryptoServiceProvider();
}
return sha256;
}
#else
#error target frameworks need to be updated.
#endif
}
}

View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Description>An antiforgery system for ASP.NET Core designed to generate and validate tokens to prevent Cross-Site Request Forgery attacks.</Description>
<TargetFrameworks>netstandard1.3;net46</TargetFrameworks>
<TargetFramework>netcoreapp2.0</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;antiforgery</PackageTags>

View File

@ -60,13 +60,7 @@ namespace Microsoft.AspNetCore.Antiforgery.Internal
identity.AddClaim(new Claim(ClaimTypes.Email, "someone@antifrogery.com"));
identity.AddClaim(new Claim(ClaimTypes.GivenName, "some"));
identity.AddClaim(new Claim(ClaimTypes.Surname, "one"));
#if NET46
// CoreCLR doesn't support an 'empty' name
identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, string.Empty));
#elif NETCOREAPP2_0
#else
#error Target framework needs to be updated
#endif
// Arrange
var claimsIdentity = (ClaimsIdentity)identity;

View File

@ -3,8 +3,7 @@
<Import Project="..\..\build\common.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net46</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>