I am trying to use Makecert.exe to create a signing certificate that I can use with our internal VS.NET applications, to be deployed using Clickonce on our local network
I have been following the MSDN guide MSDN: Certificate Expiration in ClickOnce Deployment
so I tried the below:
C:\Program Files (x86)\Microsoft Visual Studio 12.0>Makecert -sv DMTeam.pvk
-n "CN=DMTeam" DMTeam.cer -b 03/04/2015 -e 12/31/2020
in order to have a certificate for our applications
When I run the above command using the VS command prompt, I get the below error:
Error: Unable to create file for the subject ('DMTeam.pvk')
Error: Can't create the key of the subject ('DMTeam.pvk')
Failed
so what am doing wrong?
The MakeCert tool creates an X. 509 certificate, signed by the test root key or other specified key, that binds your name to the public part of the key pair. The certificate is saved to a file, a system certificate store, or both.
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.
The key is to run the command prompt with Administrator privileges.
I did something very similar, though I wrote the pvk and cer files to my c:\Temp folder:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin>MakeCert –sv C:\Temp\DMTeam.pvk –n “CN=DMTeam” c:\Temp\DMTeam.cer –b 03/04/2015 –e 12/31/2020 -r
Don't forget the "-r" option as it will "Create a self-signed certificate"! Without it the project will not build when you use the created pfx file.
I ran this under the VS2012 x86 Native Tools Command Prompt (with Run as Administrator) and it works just fine. Run without Administrative privileges and then it fails.
Then to create the pfx file do the following:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin>pvk2pfx –pvk C:\Temp\DMTeam.pvk –spc C:\Temp\DMTeam.cer –pfx –po PasswordForPFXFile
Here are some good references: See section: Test Certificates, MakeCert, RenewCert, and The Big Workaround https://msdn.microsoft.com/en-us/library/ff369721.aspx
https://msdn.microsoft.com/en-us/library/bfsktky3(v=vs.110).aspx
ClickOnce signer's certificate not valid for signing when using makecer/pvk2pfx
My ClickOnce app now builds fine in Visual Studio 2013.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With