使用mage.exe签名的ClickOnce VSTO解决方案 - 证书不可信任错误

Mar*_*tin 8 deployment clickonce vsto certificate mage

我正在尝试使用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
Run Code Online (Sandbox Code Playgroud)

我唯一的领导是,在重新签名后,publisherIdentity元素中的值不会更改(.vsto和.manifest),只有Signature元素具有与新证书对应的值.

以下命令用于签署.vsto和.manifest文件(据我从部署脚本中可以看到):

mage.exe -Update "[path to .vsto/.manifest]"
mage.exe -Sign "[path to .vsto/.manifest]" -CertHash [certificateHash]
Run Code Online (Sandbox Code Playgroud)

其中[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()
Run Code Online (Sandbox Code Playgroud)

.

小智 16

Windows不信任应用程序签名的证书.作为一种解决方案,

  1. 右键单击setup.exe,
  2. properties然后 选择Digital Signatures选项卡
  3. 选择Vellaichamy/user然后单击 Details
  4. 单击View Certificate并单击Install Certificate.

不要让它自动选择存储sert的位置,将证书安装在受信任的根证书颁发机构存储中.安装证书后,应用程序应安装...


Mar*_*tin 1

我们已经找到问题所在了。我们使用 Windows SDK 中名为 7A 的文件夹中的 mage.exe 工具版本(抱歉,我不记得完整路径)。随后,一位同事发现了另一个文件夹,其中包含版本 7A、8 和 8A。一旦我们从 8A 文件夹中获取 .exe,安装就会按预期进行。