我正在使用Windows 10。当我尝试运行生成证书的命令时,如makecert.exe
,
我发现我没有makecert.exe
,并出现以下错误:
'makecert' 不是内部或外部命令,可执行程序或批处理文件。
我已安装Windows 10的Windows SDK。
我正在使用Windows 10。当我尝试运行生成证书的命令时,如makecert.exe
,
我发现我没有makecert.exe
,并出现以下错误:
'makecert' 不是内部或外部命令,可执行程序或批处理文件。
我已安装Windows 10的Windows SDK。
它可能已经被安装,但很可能不在路径中。
比如,在C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64
下可以找到它,但你也可以在C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x86
下找到另一个。路径中的确切版本将根据你安装的SDK的版本而变化。
然而,这两个路径都没有被包含在我的PATH
环境变量中(我也不记得在安装SDK后明确地删除它),所以我不能在命令行中直接输入makecert
,我必须提供我想要运行的完整路径。
一种方便的查找拷贝所在位置的方法是使用where
命令。这里我将搜索限定在SDK目录下,但如果你愿意,你可以搜索整个硬盘:
C:\Users\Damien>where /R "C:\Program Files (x86)\Windows Kits" makecert.*
C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\arm64\makecert.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64\makecert.exe
C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x86\makecert.exe
当前 makecert 已不再使用,新方法需要使用管理员权限的 powershell 'New-SelfSignedCertificate',例如:
1.- We create a new root trusted cert:
$rootCert = New-SelfSignedCertificate -Subject 'CN=TestRootCA,O=TestRootCA,OU=TestRootCA' -KeyExportPolicy Exportable -KeyUsage CertSign,CRLSign,DigitalSignature -KeyLength 2048 -KeyUsageProperty All -KeyAlgorithm 'RSA' -HashAlgorithm 'SHA256' -Provider 'Microsoft Enhanced RSA and AES Cryptographic Provider'
2.- We create the cert from the root trusted cert chain:
New-SelfSignedCertificate -DnsName "localhost" -FriendlyName "MyCert" -CertStoreLocation "cert:\LocalMachine\My" -Signer $rootCert -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1") -Provider "Microsoft Strong Cryptographic Provider" -HashAlgorithm "SHA256" -NotAfter (Get-Date).AddYears(10)
3.- We copy the thumbprint returned by the last command
4.- (If neccesary) We remove the last association ip/port/cert:
netsh http delete sslcert ipport=0.0.0.0:443
5.- We associate the new certificate with any ip and port 443 (the appid value does not matter, is any valid guid):
netsh http add sslcert ipport=0.0.0.0:443 appid='{214124cd-d05b-4309-9af9-9caa44b2b74a}' certhash=here_the_copied_thumbprint
6.- Now, you must open MMC (Certificates Local Computer) and drag and drop the 'TestRootCA' certificate from your 'Personal/Certificates' subfolder to 'Trusted Root Certification Authorities/Certificates' subfolder.
这些命令还可以解决后来 Google Chrome 返回的“ERR_CERT_WEAK_SIGNATURE_ALGORITHM”错误,因为证书是使用 SHA1 而不是 SHA256 创建的。
New-SelfSignedCertificate
需要 PowerShell v.4 或更高版本(相当于 Windows v8.1 / Windows Server 2012 R2 或更高版本的开箱即用)。 - BuvinJC:\Users\<yourwindowslogin>\AppData\Local\Programs\Fiddler\makecert.exe
以下是我安装makecert.exe文件的步骤:
(注意:我首先安装了Windows 10 SDK,但该版本并未在“bin”目录中安装makecert.exe。没关系!)
10.0.18362.0
套件。 - BuvinJ然后在命令提示符中运行以下命令:
Makecert -r -pe -n CN="MycomputerCertificate" -b 01/01/2020 -e 12/22/2030 -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localmachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12