.NET ClickOnce签名会导致“未知发布者”

Wil*_*len 4 .net clickonce manifest authenticode

我正在努力在.NET 4.5上部署ClickOnce应用程序构建,这是事实:

  1. 我有一个有效的Comodo Authenticode证书
  2. 证书已安装在我的本地证书存储中
  3. “签名”选项卡的项目属性显示,应使用证书对清单进行签名(我什至尚未尝试对.NET的程序集进行签名)
  4. 为comodo输入了正确的时间戳服务器URL
  5. 在“发布”选项卡上,设置非常典型:
  6. 发布到UNC路径
  7. 安装文件夹是映射到IIS中该路径的URL

但是,无论我做什么,当我使用“立即发布”按钮实际发布ClickOnce应用程序时,所有文件都会被发布,但是当我下载“ Setup.exe”时,它总是说“ Unknown Publisher”。

关于我在做什么错的任何想法吗?我已经对此进行了数周的研究,并且已经阅读了足够的内容,以至于我在“正确”地进行了操作,但是我只是必须缺少一些小的复选框或设置,或者是某些东西。

任何帮助表示赞赏。

-工作组

Ari*_*rin 5

据我所知,“ Unknown Publisher”取消了代码签名,而Visual Studio并未为其提供接口。哦,它确实具有签名接口,但仅用于清单签名和强名称程序集签名。这另一个问题也提到了三个签名。

要用您的组织名称替换“未知发布者”,您必须在.csproj或.vbproj文件中添加一些XML。在结束</Project>标记之前,您需要调用SignTool.exe,我已将其手动复制到解决方案的主Bin文件夹中(如果没有,则为Windows SDK的一部分)。这是我的样子:

  <!-- This section is used for code-signing the application. This should not be confused with manifest signing or with strong-name assembly signing, which can both be done from the Visual Studio interface. -->
  <Target Name="SignOutput" AfterTargets="CoreCompile">
    <PropertyGroup>
      <TimestampServerUrl>http://timestamp.verisign.com/scripts/timstamp.dll</TimestampServerUrl>
      <ApplicationDescription>A.Franklin's Awesome App</ApplicationDescription>
      <SigningCertificateCriteria>/sha1 0c0ff5e29404b7d78q2517f487da0b1a0912c4da</SigningCertificateCriteria>
    </PropertyGroup>
    <ItemGroup>
      <SignableFiles Include="$(ProjectDir)obj\$(ConfigurationName)\$(TargetName)$(TargetExt)" />
    </ItemGroup>
    <Exec Command="&quot;$(ProjectDir)..\Bin\SignTool&quot; sign $(SigningCertificateCriteria) /d &quot;$(ApplicationDescription)&quot; /t &quot;$(TimestampServerUrl)&quot; &quot;%(SignableFiles.Identity)&quot;" />
  </Target>
Run Code Online (Sandbox Code Playgroud)

要获取我已经安装在计算机上的证书的哈希码(上面的“ 0c0ff5 ...”),我

  1. 运行certmgr.msc并打开证书–当前用户>个人>证书
  2. 双击我想要的证书,然后单击“详细信息”选项卡
  3. Used Ctrl-C to copy the value for Thumbprint (which looked like "0c f0 f5..."), except for the first character. There’s an invisible character in this textbox that gets copied along with the first character, and it messes up your script later on. So manually type the first character (a "0" in this case), then paste the value from this dialog box. If you get the error, "Invalid SHA1 hash format: ?0c 0f f5..." in Visual Studio, that question mark means the invisible character is there.
  4. Manually type the first character, then paste the value from this dialog box. Delete all spaces, so that it looks like 0c0ff5..., and make the line look like the SigningCertificateCriteria code above.

You could use SignTool.exe manually too, but for me this setup runs it transparently during each compile.