.net - 如何将 .snk 文件转换为 .pfx 文件

标签 .net assembly-signing

如何将 .snk 文件(用于对 .NET 程序集进行强名称签名)转换为适用于相同目的的受密码保护的 .pfx 文件?

编辑:澄清一下,假设我在 VS 和项目属性中创建一个项目,签名,单击“新建强名称 key 文件”,并选择不使用密码保护 key 文件:

CreateStrongKeyVS

现在想象一下,一年后我改变了主意,想添加一个密码——而不是通过创建一个新的 key 对来破坏程序集的身份。我该怎么做呢?

最佳答案

您无需转换,但是您可以使用 Strong Name Tool (Sn.exe) 对现有的 snk 文件进行签名。 . (如果 snk 已经受到保护,则涉及一些步骤,因为您需要从证书中拆分强名称部分)。

pfx 是在您选择密码保护选项时在 Visual Studio 中为您创建的私有(private)证书。您输入的密码用于保护此证书。

这是用于开发还是用于商业发布?我不建议使用私钥对程序集进行签名以进行开发。

来自 CLR Inside Out Article :

While password-protecting your key files is a much better solution than storing them in the clear, it is still not ideal. You would still have to distribute the PFX file to all of your developers, and they would all have to know the password for the PFX file. Secrets that are widely shared like this do not tend to stay secret for very long. Ideally, you should not have to distribute the private key to build and test your code during development.



阅读 Using Strong Name Signatures 上的 CLR Inside Out (MSDN) 文章.

高温下,

关于.net - 如何将 .snk 文件转换为 .pfx 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7643186/

相关文章:

c# - 监视自定义 Windows 服务

.net - String.Format 与否?

.net - 我应该使用哪个 sn.exe?

c# - 了解 .NET 程序集签名

javascript - 握手期间 ASP.NET Core WebSocket 失败

c# - 如何为 C# 项目设置 Gitlab CI 作业工件?

c# - 在 C# .NET 中管理多线程,控制每个操作的线程数

manifest - 验证 list 和应用程序文件的签名

c# - 我是否需要为开源项目保护我的强名称 key 文件?

visual-studio - 何时应使用密码保护强名称 key 文件?