我正在尝试使用ClickOnce部署VSTO解决方案,该解决方案是Word和Outlook的2个加载项。由于我们的部署基础结构/实践,我无法使用Visual Studio发布它,而是将其构建在构建服务器上,并通过部署服务器进行部署。
对于本地开发,使用自签名证书。部署使用此自签名证书(如果在计算机上安装了自签名证书),但是现在我想添加真实的公司证书,以便可以将应用程序部署到用户。
在部署期间,戳入配置文件后,将更新它们并使用真实证书对其重新签名。但是,这在安装过程中产生以下错误:
System.Security.SecurityException: Customized functionality in this application will not work because the certificate used to sign the deployment manifest for <app name> or its location is not trusted. Contact your administrator for further assistance.
at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInTrustEvaluator.VerifyTrustPromptKeyInternal(ClickOnceTrustPromptKeyValue promptKeyValue, DeploymentSignatureInformation signatureInformation, String productName, TrustStatus status)
at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInTrustEvaluator.VerifyTrustUsingPromptKey(Uri manifest, DeploymentSignatureInformation signatureInformation, String productName, TrustStatus status)
at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInTrustEvaluator.VerifyTrustUsingPromptKey(Uri manifest, DeploymentSignatureInformation signatureInformation, String productName)
at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.ProcessSHA1Manifest(ActivationContext context, DeploymentSignatureInformation signatureInformation, PermissionSet permissionsRequested, Uri manifest, ManifestSignatureInformationCollection signatures, AddInInstallationStatus installState)
at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.VerifySecurity(ActivationContext context, Uri manifest, AddInInstallationStatus installState)
at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()
The Zone of the assembly that failed was:
MyComputer
我唯一拥有的线索是,重新签名后,PublisherIdentity元素中的值未更改(.vsto和.manifest),只有Signature元素具有与新证书相对应的值。
以下命令用于对.vsto和.manifest文件进行签名(据我从部署脚本中看到的那样):
mage.exe -Update "[path to .vsto/.manifest]"
mage.exe -Sign "[path to .vsto/.manifest]" -CertHash [certificateHash]
其中[certificateHash]是真实证书的指纹,用于在证书存储区中查找证书。有人告诉我,这是安全措施,因此不必与部署包一起分发证书文件。
签名后,文件的Signature值会更改,但是PublisherIdentity仍具有自签名证书的名称和issuerKeyHash。
我尝试在重新签名之前戳入这两个值,但是我不知道如何计算issuerKeyHash。
任何建议如何进行将不胜感激!
编辑:
我正在尝试其他mage.exe参数,例如“-TrustLevel FullTrust”(没有任何效果)或“-UseManifestForTrust True”以及Name和Publisher参数,它们产生了此错误消息(与错误消息不同)上文提到的)。
************** Exception Text **************
System.InvalidOperationException: You cannot specify a <useManifestForTrust> element for a ClickOnce application that specifies a custom host.
at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.GetManifests(TimeSpan timeout)
at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()
。
最佳答案
Windows不信任使用该应用程序签名的证书。作为解决方法,
setup.exe
,properties
,然后选择Digital Signatures
选项卡Details
View Certificate
,然后单击Install Certificate
。 不要让它自动选择将证书存储在哪里,而是将证书安装在“受信任的根证书颁发机构”存储中。证书安装完成后,应用程序应会安装...
关于deployment - ClickOnce VSTO解决方案已使用mage.exe签名-证书不可信错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28720277/