Skip to content

Commit

Permalink
Refactoring xplat verification changes to address the unfinished comm…
Browse files Browse the repository at this point in the history
…ents (NuGet#3571)

Refactoring xplat verification changes to address the unfinished comments (NuGet#3571)
  • Loading branch information
heng-liu authored Aug 11, 2020
1 parent e88a5a0 commit 91084d0
Show file tree
Hide file tree
Showing 53 changed files with 94 additions and 253 deletions.
11 changes: 5 additions & 6 deletions build/common.project.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
<NETFXTargetFrameworkVersion>v4.7.2</NETFXTargetFrameworkVersion>
<NETFXTargetFramework>net472</NETFXTargetFramework>
<NETCoreTargetFramework>netcoreapp2.1</NETCoreTargetFramework>
<NETCoreTargetFrameworksForSigning>$(NETCoreTargetFramework);netcoreapp5.0</NETCoreTargetFrameworksForSigning>
<IsBuildOnlyXPLATProjects>$(DotNetBuildFromSource)</IsBuildOnlyXPLATProjects>
<NETCoreTargetFrameworks Condition=" '$(RequiresSigningXplatAPIs)' != 'true' ">netcoreapp2.1</NETCoreTargetFrameworks>
<NETCoreTargetFrameworks Condition=" '$(RequiresSigningXplatAPIs)' == 'true' ">netcoreapp2.1;netcoreapp5.0</NETCoreTargetFrameworks>
<NETCoreTestTargetFrameworks>netcoreapp3.1;netcoreapp5.0</NETCoreTestTargetFrameworks>
<NETCoreTestTargetFramework>netcoreapp5.0</NETCoreTestTargetFramework>
<NetStandardVersion>netstandard2.0</NetStandardVersion>
<TargetFrameworksExe>$(NETFXTargetFramework);$(NETCoreTargetFrameworks)</TargetFrameworksExe>
<TargetFrameworksExe>$(NETFXTargetFramework);$(NETCoreTargetFramework)</TargetFrameworksExe>
<TargetFrameworksExe Condition="'$(IsBuildOnlyXPLATProjects)' == 'true'">$(NETCoreTargetFramework)</TargetFrameworksExe>
<TargetFrameworksLibrary Condition=" '$(RequiresSigningXplatAPIs)' != 'true' ">$(NETFXTargetFramework);$(NetStandardVersion)</TargetFrameworksLibrary>
<TargetFrameworksLibrary Condition=" '$(RequiresSigningXplatAPIs)' == 'true' ">$(NETFXTargetFramework);$(NetStandardVersion);netcoreapp5.0</TargetFrameworksLibrary>
<TargetFrameworksExeForSigning>$(TargetFrameworksExe);netcoreapp5.0</TargetFrameworksExeForSigning>
<TargetFrameworksLibrary>$(NETFXTargetFramework);$(NetStandardVersion)</TargetFrameworksLibrary>
<TargetFrameworksLibrary Condition="'$(IsBuildOnlyXPLATProjects)' == 'true'">$(NetStandardVersion)</TargetFrameworksLibrary>
<TargetFrameworksLibraryForSigning>$(TargetFrameworksLibrary);netcoreapp5.0</TargetFrameworksLibraryForSigning>
<RepositoryRootDirectory>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'README.md'))\</RepositoryRootDirectory>
<BuildCommonDirectory>$(RepositoryRootDirectory)build\</BuildCommonDirectory>
<SolutionFile>$(RepositoryRootDirectory)$(RepositoryName).sln</SolutionFile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<Project>
<PropertyGroup>
<RequiresSigningXplatAPIs>true</RequiresSigningXplatAPIs>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'README.md'))\build\common.props" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />


<PropertyGroup>
<TargetFrameworks>$(TargetFrameworksLibrary)</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworksLibraryForSigning)</TargetFrameworks>
<TargetFramework />
<Shipping>true</Shipping>
<IncludeInVSIX>true</IncludeInVSIX>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<Project>
<PropertyGroup>
<RequiresSigningXplatAPIs>true</RequiresSigningXplatAPIs>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'README.md'))\build\common.props" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFrameworks Condition=" '$(IsVsixBuild)' != 'true' ">$(TargetFrameworksExe)</TargetFrameworks>
<TargetFrameworks Condition=" '$(IsVsixBuild)' != 'true' ">$(TargetFrameworksExeForSigning)</TargetFrameworks>
<TargetFramework Condition=" '$(IsVsixBuild)' == 'true' ">$(NETFXTargetFramework)</TargetFramework>
<OutputType>Exe</OutputType>
<Shipping>true</Shipping>
Expand Down
6 changes: 1 addition & 5 deletions src/NuGet.Core/NuGet.Build.Tasks/NuGet.Build.Tasks.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<Project>
<PropertyGroup>
<RequiresSigningXplatAPIs>true</RequiresSigningXplatAPIs>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'README.md'))\build\common.props" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFrameworks>$(TargetFrameworksLibrary)</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworksLibraryForSigning)</TargetFrameworks>
<TargetFramework />
<Shipping>true</Shipping>
<IncludeInVSIX>true</IncludeInVSIX>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<Project>
<PropertyGroup>
<RequiresSigningXplatAPIs>true</RequiresSigningXplatAPIs>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'README.md'))\build\common.props" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<Description>NuGet executable wrapper for the dotnet CLI nuget functionality.</Description>
<TargetFrameworks>$(TargetFrameworksExe)</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworksExeForSigning)</TargetFrameworks>
<RuntimeIdentifier Condition=" '$(TargetFramework)' == '$(NETFXTargetFramework)' ">win7-x86</RuntimeIdentifier>
<NoWarn>$(NoWarn);CS1591;CS1701</NoWarn>
<OutputType>Exe</OutputType>
Expand Down
6 changes: 1 addition & 5 deletions src/NuGet.Core/NuGet.Commands/NuGet.Commands.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<Project>
<PropertyGroup>
<RequiresSigningXplatAPIs>true</RequiresSigningXplatAPIs>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'README.md'))\build\common.props" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<Description>Complete commands common to command-line and GUI NuGet clients.</Description>
<TargetFrameworks>$(TargetFrameworksLibrary)</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworksLibraryForSigning)</TargetFrameworks>
<TargetFramework />
<NoWarn>$(NoWarn);CS1591;CS1574;CS1573;CS1584;CS1658</NoWarn>
<NoWarn Condition=" $(TargetFramework.StartsWith('netstandard')) OR $(TargetFramework.StartsWith('netcoreapp')) ">$(NoWarn);CS1998</NoWarn>
Expand Down
6 changes: 1 addition & 5 deletions src/NuGet.Core/NuGet.Credentials/NuGet.Credentials.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<Project>
<PropertyGroup>
<RequiresSigningXplatAPIs>true</RequiresSigningXplatAPIs>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'README.md'))\build\common.props" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<Description>NuGet client's authentication models.</Description>
<TargetFrameworks>$(TargetFrameworksLibrary)</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworksLibraryForSigning)</TargetFrameworks>
<TargetFramework />
<Shipping>true</Shipping>
<PackProject>true</PackProject>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<Project>
<PropertyGroup>
<RequiresSigningXplatAPIs>true</RequiresSigningXplatAPIs>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'README.md'))\build\common.props" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFrameworks>$(TargetFrameworksLibrary)</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworksLibraryForSigning)</TargetFrameworks>
<TargetFramework />
<NoWarn>$(NoWarn);CS1591;CS1574</NoWarn>
<PackProject>true</PackProject>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<Project>
<PropertyGroup>
<RequiresSigningXplatAPIs>true</RequiresSigningXplatAPIs>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'README.md'))\build\common.props" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<Description>The (former home to) core data structures for NuGet.Packaging. Contains only the type forwarders to the new assembly.</Description>
<TargetFrameworks>$(TargetFrameworksLibrary)</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworksLibraryForSigning)</TargetFrameworks>
<TargetFramework />
<NoWarn>$(NoWarn);CS1591</NoWarn>
<PackProject>true</PackProject>
Expand Down
6 changes: 1 addition & 5 deletions src/NuGet.Core/NuGet.Packaging/NuGet.Packaging.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<Project>
<PropertyGroup>
<RequiresSigningXplatAPIs>true</RequiresSigningXplatAPIs>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'README.md'))\build\common.props" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<Description>NuGet's understanding of packages. Reading nuspec, nupkgs and package signing.</Description>
<TargetFrameworks>$(TargetFrameworksLibrary)</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworksLibraryForSigning)</TargetFrameworks>
<TargetFramework />
<NoWarn>$(NoWarn);CS1591;CS1574;CS1573;CS1572</NoWarn>
<NoWarn Condition=" $(TargetFramework.StartsWith('netstandard')) OR $(TargetFramework.StartsWith('netcoreapp'))">$(NoWarn);CS0414</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 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.

#if IS_SIGNING_SUPPORTED
using System;
using System.Threading.Tasks;

Expand All @@ -17,3 +18,4 @@ internal interface IRfc3161TimestampRequest
byte[] GetNonce();
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// 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.

#if IS_SIGNING_SUPPORTED
using System.Security.Cryptography.Pkcs;

namespace NuGet.Packaging.Signing
{
internal interface IRfc3161TimestampToken
{
#if IS_SIGNING_SUPPORTED
IRfc3161TimestampTokenInfo TokenInfo { get; }

SignedCms AsSignedCms();
#endif
}
}
#endif

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// 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.

#if IS_SIGNING_SUPPORTED
using System;
using System.Security.Cryptography;

namespace NuGet.Packaging.Signing
{
internal interface IRfc3161TimestampTokenInfo
{
#if IS_SIGNING_SUPPORTED
string PolicyId { get; }

DateTimeOffset Timestamp { get; }
Expand All @@ -20,6 +20,6 @@ internal interface IRfc3161TimestampTokenInfo
bool HasMessageHash(byte[] hash);

byte[] GetNonce();
#endif
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if IS_DESKTOP
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
Expand All @@ -17,8 +18,6 @@ namespace NuGet.Packaging.Signing
/// </summary>
internal sealed class Rfc3161TimestampRequest : AsnEncodedData
{

#if IS_DESKTOP
private class DataType
{
internal int _version;
Expand Down Expand Up @@ -422,6 +421,6 @@ public override void CopyFrom(AsnEncodedData asnEncodedData)
_data = null;
base.CopyFrom(asnEncodedData);
}
#endif
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 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.

#if IS_SIGNING_SUPPORTED
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
Expand All @@ -21,7 +22,7 @@ public static IRfc3161TimestampRequest Create(
{
throw new ArgumentNullException(nameof(messageHash));
}
#if IS_SIGNING_SUPPORTED

IRfc3161TimestampRequest iRfc3161TimestampRequest = null;
#if IS_DESKTOP
iRfc3161TimestampRequest = new Rfc3161TimestampRequestNet472Wrapper(
Expand All @@ -41,9 +42,8 @@ public static IRfc3161TimestampRequest Create(
extensions);
#endif
return iRfc3161TimestampRequest;
#else
throw new NotSupportedException();
#endif

}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// 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.

#if IS_SIGNING_SUPPORTED && IS_DESKTOP
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;

namespace NuGet.Packaging.Signing
{
#if IS_SIGNING_SUPPORTED && IS_DESKTOP
internal sealed class Rfc3161TimestampRequestNet472Wrapper : IRfc3161TimestampRequest
{
private readonly Rfc3161TimestampRequest _rfc3161TimestampRequest;
Expand Down Expand Up @@ -40,5 +40,5 @@ public byte[] GetNonce()
return _rfc3161TimestampRequest.GetNonce();
}
}
#endif
}
#endif
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// 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.

#if IS_SIGNING_SUPPORTED && IS_CORECLR
using System;
using System.Globalization;
#if IS_SIGNING_SUPPORTED && IS_CORECLR
using System.Net.Http;
using System.Net.Http.Headers;
#endif
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;

namespace NuGet.Packaging.Signing
{
#if IS_SIGNING_SUPPORTED && IS_CORECLR
internal sealed class Rfc3161TimestampRequestNetstandard21Wrapper : IRfc3161TimestampRequest
{
private static readonly HttpClient HttpClient = new HttpClient();
Expand Down Expand Up @@ -87,5 +85,5 @@ public byte[] GetNonce()
return normalizedNonce.HasValue ? normalizedNonce.Value.ToArray() : null;
}
}
#endif
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if IS_DESKTOP
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security.Cryptography;

#if IS_DESKTOP
using System.Security.Cryptography.Pkcs;
#endif

using System.Security.Cryptography.X509Certificates;

namespace NuGet.Packaging.Signing
Expand All @@ -21,9 +18,6 @@ namespace NuGet.Packaging.Signing
/// </summary>
internal sealed class Rfc3161TimestampToken
{

#if IS_DESKTOP

private readonly byte[] _encoded;

public IRfc3161TimestampTokenInfo TokenInfo { get; }
Expand Down Expand Up @@ -155,6 +149,6 @@ private static Rfc3161TimestampToken CryptVerifyTimeStampSignature(byte[] encode
Rfc3161TimestampWin32.CertCloseStore(hStore, 0);
}
}
#endif
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 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.

#if IS_SIGNING_SUPPORTED
using System;
using System.Security.Cryptography.X509Certificates;

Expand Down Expand Up @@ -33,7 +34,7 @@ public static IRfc3161TimestampToken Create(
{
throw new ArgumentNullException(nameof(encoded));
}
#if IS_SIGNING_SUPPORTED

IRfc3161TimestampToken iRfc3161TimestampToken = null;
#if IS_DESKTOP
iRfc3161TimestampToken = new Rfc3161TimestampTokenNet472Wrapper(
Expand All @@ -49,9 +50,7 @@ public static IRfc3161TimestampToken Create(
encoded);
#endif
return iRfc3161TimestampToken;
#else
throw new NotSupportedException();
#endif
}
}
}
#endif
Loading

0 comments on commit 91084d0

Please sign in to comment.