简体   繁体   English

使用已安装证书的强名称程序集

[英]Strong name assembly using installed certificate

Certmgr shows I have my company's Symantec Class 3 SHA256 Code Signing CA installed, along with ones with Private in the name. Certmgr 显示我安装了我公司的 Symantec Class 3 SHA256 代码签名 CA,以及名称中带有 Private 的 CA。 Can I add this line to my Assembly Info:我可以将此行添加到我的程序集信息中吗:

[assembly: AssemblyKeyName("what name do I use here?")]

to strongly-name an assembly at build time?在构建时强命名程序集? Would that find the public/private key pair in the certificate store and insert them into my assembly?那会在证书存储中找到公钥/私钥对并将它们插入我的程序集中吗? Or do I have to extract the public/private key pair from the certificates and use the well-documented process for strong-naming that I see all over the Internet?或者我是否必须从证书中提取公钥/私钥对并使用我在互联网上看到的有据可查的过程进行强命名?

I've tried the above with variations of the company name but build fails with:我已经尝试了上述公司名称的变体,但构建失败:

Keyset does not exist键集不存在

Here is a blog post that explains what needs to be done: https://matthewdippel.blogspot.com/2017/09/howto-strong-name-sign-net-assembly.html这是一篇解释需要做什么的博客文章: https://matthewdippel.blogspot.com/2017/09/howto-strong-name-sign-net-assembly.html

However, there's an ugly catch-22.但是,有一个丑陋的 catch-22。 Running sn.exe -c, if it ends up changing the CSP, can only be done as an elevated user.运行 sn.exe -c,如果它最终更改 CSP,则只能作为提升的用户执行。 However, that same elevated user cannot access the key in the personal store of your non-elevated account.但是,同一提升的用户无法访问您的非提升帐户的个人存储中的密钥。 So simply adding this to the pre-build or post-build and running Visual Studio under elevation results in the exact same Keyset not found error on build.因此,只需将其添加到预构建或构建后并在提升下运行 Visual Studio 会导致构建时出现完全相同的 Keyset not found 错误。 ... To get this working, you'll need the script located at this gist . ...要使其正常工作,您需要位于此 gist 的脚本 The only requirement is that you have the.Net Framework SDK 4.6, 4.6.1 or 4.6.2 installed.唯一的要求是您安装了 .Net Framework SDK 4.6、4.6.1 或 4.6.2。 It uses it to get the path to the sn.exe file so that it'll work regardless of how your system is configured.它使用它来获取 sn.exe 文件的路径,这样无论您的系统如何配置,它都能正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM