From f7f0b1924904ec7f2792c0a7805a4d0e91ac8955 Mon Sep 17 00:00:00 2001 From: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com> Date: Tue, 28 Nov 2023 10:32:45 +0100 Subject: [PATCH] Fix issue with SHA256 instantiation (#9429) --- .../Microsoft.Build.Tasks.UnitTests.csproj | 6 ++ src/Tasks.UnitTests/SecurityUtil_Tests.cs | 81 ++++++++++++++++++ .../TestResources/ClickOnceProfile.pubxml | 11 +++ src/Tasks.UnitTests/TestResources/mycert.pfx | Bin 0 -> 2590 bytes src/Tasks/ManifestUtil/mansign2.cs | 8 +- 5 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 src/Tasks.UnitTests/SecurityUtil_Tests.cs create mode 100644 src/Tasks.UnitTests/TestResources/ClickOnceProfile.pubxml create mode 100644 src/Tasks.UnitTests/TestResources/mycert.pfx diff --git a/src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj b/src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj index 733ef007645..6b3d539cacf 100644 --- a/src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj +++ b/src/Tasks.UnitTests/Microsoft.Build.Tasks.UnitTests.csproj @@ -166,8 +166,14 @@ PreserveNewest + + PreserveNewest + PreserveNewest + + PreserveNewest + diff --git a/src/Tasks.UnitTests/SecurityUtil_Tests.cs b/src/Tasks.UnitTests/SecurityUtil_Tests.cs new file mode 100644 index 00000000000..92bcfaf08c8 --- /dev/null +++ b/src/Tasks.UnitTests/SecurityUtil_Tests.cs @@ -0,0 +1,81 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.ConstrainedExecution; +using System.Runtime.Versioning; +using System.Security.Cryptography; +using System.Security.Cryptography.X509Certificates; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Build.Tasks.Deployment.ManifestUtilities; +using Shouldly; +using Xunit; + +namespace Microsoft.Build.Tasks.UnitTests +{ + public class SecurityUtil_Tests + { + private static string TestAssembliesPaths { get; } = Path.Combine(AppContext.BaseDirectory, "TestResources"); + + [WindowsOnlyTheory] + [InlineData("v4.5", Constants.DotNetFrameworkIdentifier)] + [InlineData("v4.5", Constants.DotNetCoreAppIdentifier)] + [SupportedOSPlatform("windows")] + public void SignFile_Success(string tfVersion, string tfIdentifier) + { + Uri timestampUrl = new("http://timestamp.comodoca.com/rfc3161"); + string clickOnceManifest = Path.Combine(TestAssembliesPaths, "ClickOnceProfile.pubxml"); + string targetFrameworkVersion = tfVersion; + string targetFrameworkIdentifier = tfIdentifier; + bool disallowMansignTimestampFallback = false; + + // the certificate was generated locally and does not contain any sensitive information + string pathToCertificate = Path.Combine(TestAssembliesPaths, "mycert.pfx"); + X509Certificate2 certificate = TestCertHelper.MockCertificate(pathToCertificate); + + void SignAction() => SecurityUtilities.SignFile( + certificate?.Thumbprint, + timestampUrl, + clickOnceManifest, + targetFrameworkVersion, + targetFrameworkIdentifier, + disallowMansignTimestampFallback); + + Should.NotThrow(SignAction); + + TestCertHelper.RemoveCertificate(certificate); + } + + internal static class TestCertHelper + { + private static readonly X509Store s_personalStore = new(StoreName.My, StoreLocation.CurrentUser); + + internal static X509Certificate2 MockCertificate(string pathToCertificate) + { + var certificate = new X509Certificate2(pathToCertificate); + UpdateCertificateState(certificate, s_personalStore.Add); + + return certificate; + } + + internal static void RemoveCertificate(X509Certificate2 certificate) => UpdateCertificateState(certificate, s_personalStore.Remove); + + private static void UpdateCertificateState(X509Certificate2 certificate, Action updateAction) + { + try + { + s_personalStore.Open(OpenFlags.ReadWrite); + updateAction(certificate); + } + finally + { + s_personalStore.Close(); + } + } + } + } +} diff --git a/src/Tasks.UnitTests/TestResources/ClickOnceProfile.pubxml b/src/Tasks.UnitTests/TestResources/ClickOnceProfile.pubxml new file mode 100644 index 00000000000..0f18e1617e4 --- /dev/null +++ b/src/Tasks.UnitTests/TestResources/ClickOnce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Qm5+i82UkfZhBYTZ+6gJ8Elt0W54EWouDoORWkBZEai+fB5NOx/3Vt6Ku8GrGV3DMXxUPxKNLFtecruLJ9c5Yduw3lRKTCEppajog8VJ73XglXZLu82WgHNyVDn+xCperyOILWkcTo3xheCVvlYgDCrJqrWGY0sg/NOwrKaCBN8ZY9vLGMifvQ3Cltvmw4SKOxaRjdiKr6mTP7uC/DDLJLwkBujaESnnwsgM9DptdVyZqSi5FlNH5nmzyFD3z7wBeMdstGX/m7Ag2jeyr2cX5TGfC3GrMiz3spG8Lsl8CZW6JriYuH3EWSA2cEaZAnxB22nLNar3kP8rknIdReMZybBrfDu/cQre+1PtYNaunJvZXlQQGI96qfdLhQTWaTQfWwLq2A39p7dBWS+4/qzxG0H80MKaSCfT+TNKxORvj8tqEbxAo7YBGdPOQzui7OEmaOoe+ecFFBN9cnEzSHn54CAwJodo6bPoo1lXmBcasJqFO5XrDXFUX7Q6VCwJF/l1AxvS5wl8jN0rs/QIy69QIjGVUaghnSZsBcypUM3IZXFvPN85TSUlIw9WgWq3vnK/4YHDAnBd8FlacjexruIUc0hB7KM= diff --git a/src/Tasks.UnitTests/TestResources/mycert.pfx b/src/Tasks.UnitTests/TestResources/mycert.pfx new file mode 100644 index 0000000000000000000000000000000000000000..2809e31eb9b2d0105099517be56ac4d2d382cb2c GIT binary patch literal 2590 zcmZXVc{tQv8^?dM7)Ho0OZJ@@+n6ZISVNSo)r6tpwUsTR)YwDzELmp6pe)&vWD5@l zsYqq)JSO{+UGe^UuJ?VO>%HFVT=zNO`|~~bef~P#K3|lB7!#Wtth-3e$Vqu0rNksS|iU{9F2_cyOi^1k> zaHjH`I#EKWxe-t(;|Dkq{*^|?!tin1Jdk}fen2*UJ~&ml6Ys0Pa3`=3t{60rEaS__ zti@w%C6J}^Y^{XY-eE#2n|Joq99?$6JFsK;v9^v%JTDW!jRo;zj77HbYAX35Zs4kP zz{$_Q@U^2K>EWEJ4pw}-(Gx=^) z`nutmVn=1`W|sl-8C@xj`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/ManifestUtil/mansign2.cs +++ b/src/Tasks/ManifestUtil/mansign2.cs @@ -270,10 +270,14 @@ private void init() Sha256SignatureMethodUri); #if RUNTIME_TYPE_NETCORE - CryptoConfig.AddAlgorithm(typeof(SHA256), +#pragma warning disable SYSLIB0021 // Type or member is obsolete + // SHA256 can not be used since it is an abstract class. + // CalculateHashValue internally calls CryptoConfig.CreateFromName and it causes instantiation problems. + CryptoConfig.AddAlgorithm(typeof(SHA256Managed), Sha256DigestMethod); +#pragma warning restore SYSLIB0021 // Type or member is obsolete #else - CryptoConfig.AddAlgorithm(typeof(System.Security.Cryptography.SHA256Cng), + CryptoConfig.AddAlgorithm(typeof(SHA256Cng), Sha256DigestMethod); #endif }