dotnet / dotnet/sign

Unable to Sign ClickOnce Manifests

Open
#428 0 comments 0 reactions 0 assignees View on GitHub
investigate Priority:3
Dominant language
C#
Stars
581
Forks
116
Avg merge
1d 2h
Merged PRs (30d)
8

Description

We are recieving the following error when attempting to sign a ClickOnce Manifest file.

```
System.AggregateException: One or more errors occurred. (Could not create hash algorithm object.)
---> System.ApplicationException: Could not create hash algorithm object.
---> System.Security.Cryptography.CryptographicException: Could not create hash algorithm object.
at System.Security.Cryptography.Xml.Reference.CalculateHashValue(XmlDocument document, CanonicalXmlNodeList refList)
at System.Security.Cryptography.Xml.SignedXml.BuildDigestedReferences()
at System.Security.Cryptography.Xml.SignedXml.ComputeSignature()
at System.Deployment.Internal.CodeSigning.SignedCmiManifest2.AuthenticodeSignLicenseDom(XmlDocument licenseDom, CmiManifestSigner2 signer, String timeStampUrl, Boolean useSha256) in \SignService\src\SignService\Utils\mansign2.cs:line 502
at System.Deployment.Internal.CodeSigning.SignedCmiManifest2.Sign(CmiManifestSigner2 signer, String timeStampUrl) in \SignService\src\SignService\Utils\mansign2.cs:line 135
at SignService.Utils.ManifestSigner.SignFile(String path, HashMode hashMode, RSA rsaPrivateKey, X509Certificate2 publicCertificate, String timestampUrl) in \SignService\src\SignService\Utils\ManifestSigner.cs:line 32
--- End of inner exception stack trace ---
at SignService.Utils.ManifestSigner.SignFile(String path, HashMode hashMode, RSA rsaPrivateKey, X509Certificate2 publicCertificate, String timestampUrl) in \SignService\src\SignService\Utils\ManifestSigner.cs:line 45
at SignService.SigningTools.MageSignService.RunSignTool(String args, String inputFile, HashMode hashMode, RSA rsaPrivateKey, X509Certificate2 publicCertificate, String timestampUrl) in \SignService\src\SignService\SigningTools\MageSignService.cs:line 284
at SignService.SigningTools.MageSignService.Sign(String args, String inputFile, HashMode hashMode, RSA rsaPrivateKey, X509Certificate2 publicCertificate, String timestampUrl) in \SignService\src\SignService\SigningTools\MageSignService.cs:line 221
at SignService.SigningTools.MageSignService.<>c__DisplayClass17_0.b__0(String file, ParallelLoopState state) in \SignService\src\SignService\SigningTools\MageSignService.cs:line 151
at System.Threading.Tasks.Parallel.<>c__DisplayClass33_0`2.b__1(Int32 i, ParallelLoopState state)
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()
--- End of inner exception stack trace ---
at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException)
at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IList`1 list, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, ParallelOptions parallelOptions, Action`2 body)
at SignService.SigningTools.MageSignService.SubmitInternal(HashMode hashMode, String name, String description, String descriptionUrl, IList`1 files, String filter) in \SignService\src\SignService\SigningTools\MageSignService.cs:line 88
at SignService.SigningTools.MageSignService.<>c__DisplayClass10_0.b__0() in \SignService\src\SignService\SigningTools\MageSignService.cs:line 63
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at SignService.SigningTools.MageSignService.Submit(HashMode hashMode, String name, String description, String descriptionUrl, IList`1 files, String filter) in \SignService\src\SignService\SigningTools\MageSignService.cs:line 63
at SignService.SigningTools.SigningToolAggregate.Submit(HashMode hashMode, String name, String description, String descriptionUrl, IList`1 files, String filter) in \SignService\src\SignService\SigningTools\SigningToolAggregate.cs:line 191
at SignService.Controllers.SignController.SignFile(IFormFile source, IFormFile filelist, HashMode hashMode, String name, String description, String descriptionUrl) in \SignService\src\SignService\Controllers\SignController.cs:line 99
at lambda_method395(Closure , Object )
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Logged|12_1(ControllerActionInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
```

I haven't been able to pinpoint why it's doing this either.

Some basic information about the cert we're using is that it's a GlobalSign EV CodeSign Cert stored in a premium Key Vault (HSM storage), and that it has a SHA256 signature.
![image](https://user-images.githubusercontent.com/3457368/186005360-99cedca1-e043-4a34-b37a-508c848ffc28.png)

This works for all other files and file types, but once it comes down to performing the clickonce manifest it crashes.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.