在 C# 解决方案中创建 PFX 文件
我不小心删除了 PFX 文件。现在我想知道如何再次创建 PFX 文件。
I accidentally deleted the PFX file. Now I would like to know how to create the PFX file again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
PFX 文件是包含加密私钥的文件。它通常用于代码签名,从而实现程序集的可信执行。
如果您删除了它(并且它不再位于回收站中或无法从源代码控制服务器中获取),则无法恢复它或它包含的密钥。
您必须创建一个新密钥,这将更改程序集的公钥。在项目属性的“签名”选项卡下执行此操作。
A PFX file is one that contains an encrypted private key. It is generally used for code-signing, which enables trusted execution of an assembly.
If you deleted it (and it's not still in the Recycle Bin or available from your source control server), there's no way to recover it or the key that it contained.
You will have to create a new one, which will change the public key of your assembly. Do so in your project's Properties, under the "Signing" tab.
如果您的项目不受源代码控制并且没有备份,则必须通过“项目属性”页面的“签名”选项卡创建一个新的、不同的强名称密钥文件。请注意,执行此操作后,程序集的公钥标记将不再相同!
If your project is not under source control and you do not have a backup, you will have to create a new, different strong name key file, via the Signing tab of the Project Properties page. Be aware that the public key token of your assembly will no longer be the same after you do this!
除非您拥有原始的 public & 文件,否则无法重新生成 PFX 文件。生成它的私钥。
这些可以单独存储,通常分别存储为 .CER 和 .PVK 文件,因此您可以查看一下是否有它们的副本。
You can't regenerate the PFX file unless you have the original public & private keys that it was generated from.
These can be stored separately, usually as .CER and .PVK files respectively, so you can have a look and see if you have copies of them.
转到项目属性,单击“签名”选项卡,启用“签署 ClickOnce 清单”,然后单击“创建测试证书”。如果您想生成 snk 文件,可以通过底部的“选择强名称密钥文件”组合框来完成。
请注意,Visual Studio 生成的 pfx 的生命周期相当短(我认为是一年),因此您应该生成自己的。
Go to your project properties, click the Signing tab, enable "Sign the ClickOnce manifests", then hit Create Test Certificate. If you want to generate a snk file, you can do that via the "Choose a strong name key file" Combobox at the bottom.
Be aware that the pfx generated by Visual Studio has a rather short lifetime (I think one year), so you should generate your own.