首页 > 解决方案 > 如何将清单从 sha1 更新到 sha256?

问题描述

我在Visual Studio 2010C#.NET Framework 3.5VSTO Excel COM-Addin上有项目。最近一位客户增加了要求:需要用证书签名。我从 Sectigo 购买了“EV 证书”,我可以对我的整个设置、exe、.dll 等进行签名。但后来我尝试使用这个证书对 Project --> Properties --> "Sign the ClickOnce manifests" 进行签名,我什至不能运行项目。我在下面收到错误粘贴。

这是我第一次体验证书。似乎我的项目正在使用sha1,它已从 2017 年开始弃用。如何将我的项目更新为sha256

在清单中,例如我看到:

<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1/> <dsig:DigestValueBjwCX1w9SEEN4XGlQJVNJgdAr24=</dsig:DigestValue>

错误代码:

Exception reading manifest from file:///C:/Users/...vsto: the manifest may not be valid or the file could not be opened.

************** Exception Text **************
System.Deployment.Application.InvalidDeploymentException: Exception reading manifest from file:///C:/Users/...vsto: the manifest may not be valid or the file could not be opened. ---> System.Deployment.Application.InvalidDeploymentException: Manifest XML signature is not valid. ---> System.Security.Cryptography.CryptographicException: SignatureDescription could not be created for the signature algorithm supplied.
   at System.Security.Cryptography.Xml.SignedXml.CheckSignedInfo(AsymmetricAlgorithm key)
   at System.Security.Cryptography.Xml.SignedXml.CheckSignatureReturningKey(AsymmetricAlgorithm& signingKey)
   at System.Deployment.Internal.CodeSigning.SignedCmiManifest.Verify(CmiManifestVerifyFlags verifyFlags)
   at System.Deployment.Application.Manifest.AssemblyManifest.ValidateSignature(Stream s)
   --- End of inner exception stack trace ---
   at System.Deployment.Application.Manifest.AssemblyManifest.ValidateSignature(Stream s)
   at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.GetManifests(TimeSpan timeout)
   at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()

标签: c#visual-studiovisual-studio-2010vstosha256

解决方案


Visual Studio 2010(和 VSTO for Framework 3.5)不理解 SHA256 证书。您需要升级您的 Visual Studio 并将您的项目迁移到当前版本的 VSTO,然后它将“正常工作”。


推荐阅读