Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I keep getting a failed when trying to make a .cer for testing?

I'm trying to make a certificate for testing and I am using this site How to: Create Your Own Test Certificate as a tutorial on how to but when it comes time to enter in the password after you create the password it says failed in the command prompt why is that?

What I've done:

First, I open a command prompt and type in:

  cd C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin

Second, I type in

  makecert -sv myPrivateKeyFile.pvk -n "TestCert" myCertFile.cer -b 01/01/2011 -e 01/01/2015 -r

Then I create the password then enter the password on the sencond pop up box and then it says failed in command prompt

When I enter in this again, the popup is asking for the password pops up first this time, and I enter it in and it says:

Error: CryptCertStrToNameW failed => 0x80092023 (-2146885597)

    makecert -sv myPrivateKeyFile.pvk -n "TestCert" myCertFile.cer -b 01/01/2011 -e 01/01/2015 -r
like image 901
Shredder2500 Avatar asked Feb 29 '12 21:02

Shredder2500


4 Answers

I solved the problem by running the program as an administrator, but I had to change also the name of certificate in a LDAP style like this (CN=...):

makecert -sv myPrivateKeyFile.pvk -n "CN=TestCert" myCertFile.cer -b 01/01/2011 -e 01/01/2015 -r
like image 160
Renzo Ciot Avatar answered Nov 10 '22 08:11

Renzo Ciot


This was a bit of a shotgun-debug for me. I started with this after reading the makecert guide:

makecert.exe /b 01/01/2014 /e 01/01/2114 /len 256 /m 1200 /n "CN=In-House-Software" /pe /r /sr localMachine Test_Cert.cer

There's two error-causing flaws here:

  1. /e and /m likely are not supposed to overlap; seems kind of obvious, but they didn't document it or create an expressive error message for it.
  2. /len 256 was an invalid value -- too low. This also didn't seem too obvious/documented/expressed in a good error message. 512 did work. I didn't bother finding the floor-value, but by default 1024 is used.

I ended up using this with success:

makecert.exe /b 01/01/2014 /e 01/01/2114 /len 512 /pe /r /n "CN=In-House-Software" /sr localMachine Test_Cert.cer

like image 23
kayleeFrye_onDeck Avatar answered Nov 10 '22 10:11

kayleeFrye_onDeck


The reason why I was getting this error is, because I didn't right click on cmd when I ran it. So when you have this problem you need to right click on cmd and then run as administrator and see if that fixes your problem as it did mine.

like image 5
Shredder2500 Avatar answered Nov 10 '22 10:11

Shredder2500


I also received this error when I specified the CA name for a self-signed cert, in other words, if you specify the '-cy authority' and the '-r' options, then DON'T specify the CA name explicitly in the name via the -n option.

like image 3
david.barkhuizen Avatar answered Nov 10 '22 10:11

david.barkhuizen