Last active
November 2, 2021 06:29
-
-
Save andrewabest/d18a8656834b0f5c769c to your computer and use it in GitHub Desktop.
Create a cert authority and client certificate for development using makecert.exe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Courtesy of http://www.digitallycreated.net/Blog/38/using-makecert-to-create-certificates-for-development | |
:: Now we need to create a client certificate that is signed by our new certificate authority. You can do this one of two ways. The first way is to create a certificate and store it and its private key in the Windows Certificate Store (what you see in MMC). This is how you do that: | |
:: Note that CN must match the host name! http://technet.microsoft.com/en-au/library/dd891009.aspx | |
"c:\Program Files (x86)\Windows Kits\8.1\bin\x64\makecert.exe" -n "CN=domainnameormachienname" -ic "Certificate_Authority.cer" -iv "Certificate_Authority_Private_Key.pvk" -a sha1 -sky exchange -pe -sr localmachine -ss my "myapp.cer" | |
:: -n : The certificate name. CN stands for Common Name and is the name that | |
:: identifies the certificate. For websites, this is their domain name. | |
:: -ic : The certificate to use as the root authority | |
:: -iv : The private key of the root authority certificate | |
:: -a sha1 : Use the SHA1 algorithm | |
:: -sky exchange : Create a certificate that can do key exchange | |
:: -pe : Makes the certificate's private key exportable | |
:: -sr : The certificate store location to hold the certificate (currentuser or localmachine) | |
:: -ss : The certificate store name. my is the Personal store | |
:: *.cer : The filename to export to | |
:: It will ask you for the certificate authority's private key's password, so that it can use the private key to sign your certificate. It then will store your certificate (and its private key) in the current user's Personal store. You should be able to see it in MMC. It will also create a copy of the certificate on the hard drive. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Courtesy of http://stackoverflow.com/questions/84847/how-do-i-create-a-self-signed-certificate-for-code-signing-on-windows | |
makecert -n "CN=domainnameormachienname SPC" -ic Certificate_Authority.cer -iv Certificate_Authority_Private_Key.pvk -a sha1 -sky signature -pe -cy end -sv SPC_Private_Key.pvk SPC.cer | |
pvk2pfx -pvk SPC_Private_Key.pvk -spc SPC.cer -pfx SPC.pfx | |
:: -n : The certificate name. CN stands for Common Name and is the name that | |
:: identifies the certificate. For websites, this is their domain name. | |
:: -ic : The certificate to use as the root authority | |
:: -iv : The private key of the root authority certificate | |
:: -a sha1 : Use the SHA1 algorithm | |
:: -sky signature: Create a certificate that can do code signing | |
:: -pe : Makes the certificate's private key exportable | |
:: -cy : Specifies the certificate type. Valid values are end for end-entity and authority for certification authority. | |
:: -sv : Specifies the subject's .pvk private key file. The file is created if none exists. | |
:: *.cer : The filename to export to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will retrieve a list of all certs and their thumbprints in the LocalMachine certificate store | |
# http://technet.microsoft.com/en-us/library/hh847761.aspx here are some examples of usage | |
Get-ChildItem -Path cert:\LocalMachine -Recurse | select Subject, FriendlyName, Thumbprint | Format-List |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment