Creating a PFX file in C# solution
I accidentally d开发者_运维知识库eleted the PFX file. Now I would like to know how to create the PFX file again.
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!
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.
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.
精彩评论