Today, I needed a PFX (public key file) to sign a ClickOnce deployment. I spent a fair amount of time trying to figure this out, so I figured I’d share it!
There were plenty of suggested solutions out there, but the best one was from MSDN blogger Maxime Lamure.
In short, do the following, replacing MyCert with the certificate file name (without extension), MyName with the name you want on the certificate (your name, or a company name), and password with the PFX file password.
- Open a Visual Studio Command Prompt. If using Windows Vista or Windows 7, be sure to run as Administrator.
- Create your certificate (.cer) file by typing:
makecert -sv MyCert.pvk -n "CN=MyName" MyCert.cer
- Create your public key (.pfx) file by typing:
pvk2pfx -pvk MyCert.pvk -spc MyCert.cer -pfx MyCert.pfx -po password
At the end, you’ll have your very own certificate file and public key!