From abdd6d1ecf10ccc756e55233c7b158e4197d478a Mon Sep 17 00:00:00 2001 From: Christopher Costa Date: Wed, 14 Apr 2021 14:13:56 -0700 Subject: [PATCH] Run signcheck in single threaded apartment --- .../Microsoft.SignCheck/Verification/AuthentiCode.cs | 2 +- .../SignCheck/Microsoft.DotNet.SignCheck.csproj | 4 ++++ src/SignCheck/SignCheck/SignCheckTask.cs | 9 ++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/SignCheck/Microsoft.SignCheck/Verification/AuthentiCode.cs b/src/SignCheck/Microsoft.SignCheck/Verification/AuthentiCode.cs index 4c80e48c148..1a8e0086634 100644 --- a/src/SignCheck/Microsoft.SignCheck/Verification/AuthentiCode.cs +++ b/src/SignCheck/Microsoft.SignCheck/Verification/AuthentiCode.cs @@ -29,7 +29,7 @@ public static uint IsSigned(string path) WinTrustData data = new WinTrustData() { cbStruct = (uint)Marshal.SizeOf(typeof(WinTrustData)), - dwProvFlags = Convert.ToUInt32(Provider.WTD_SAFER_FLAG), + dwProvFlags = 0, dwStateAction = Convert.ToUInt32(StateAction.WTD_STATEACTION_IGNORE), dwUIChoice = Convert.ToUInt32(UIChoice.WTD_UI_NONE), dwUIContext = 0, diff --git a/src/SignCheck/SignCheck/Microsoft.DotNet.SignCheck.csproj b/src/SignCheck/SignCheck/Microsoft.DotNet.SignCheck.csproj index f23cb7d7794..6c7b257e95b 100644 --- a/src/SignCheck/SignCheck/Microsoft.DotNet.SignCheck.csproj +++ b/src/SignCheck/SignCheck/Microsoft.DotNet.SignCheck.csproj @@ -30,6 +30,10 @@ + + + + diff --git a/src/SignCheck/SignCheck/SignCheckTask.cs b/src/SignCheck/SignCheck/SignCheckTask.cs index 99a4d7776a9..1b40fd98456 100644 --- a/src/SignCheck/SignCheck/SignCheckTask.cs +++ b/src/SignCheck/SignCheck/SignCheckTask.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; using Microsoft.SignCheck.Logging; using System; using System.Collections.Generic; @@ -10,8 +11,12 @@ namespace SignCheck { - public class SignCheckTask : Microsoft.Build.Utilities.Task + [Microsoft.Build.Framework.LoadInSeparateAppDomain] + [RunInSTA] + public class SignCheckTask : AppDomainIsolatedTask { + static SignCheckTask() => Microsoft.DotNet.AssemblyResolution.Initialize(); + public bool EnableJarSignatureVerification { get; @@ -85,6 +90,7 @@ public string ArtifactFolder public override bool Execute() { + Microsoft.DotNet.AssemblyResolution.Log = Log; Options options = new Options(); options.EnableJarSignatureVerification = EnableJarSignatureVerification; options.EnableXmlSignatureVerification = EnableXmlSignatureVerification; @@ -143,6 +149,7 @@ public override bool Execute() var sc = new SignCheck(options); int result = sc.Run(); + Microsoft.DotNet.AssemblyResolution.Log = null; return (result == 0 && !Log.HasLoggedErrors); } }