【发布时间】:2018-07-19 08:56:02
【问题描述】:
我使用的是 Windows 10。我没有 makecert.exe,当我尝试运行命令来生成证书时才知道
makecert.exe
我得到错误:
'makecert' 未被识别为内部或外部命令, 可运行的程序或批处理文件。
我已经安装了适用于 windows 10 的 windows SDK。
【问题讨论】:
标签: c# iis configuration windows-10 makecert
我使用的是 Windows 10。我没有 makecert.exe,当我尝试运行命令来生成证书时才知道
makecert.exe
我得到错误:
'makecert' 未被识别为内部或外部命令, 可运行的程序或批处理文件。
我已经安装了适用于 windows 10 的 windows SDK。
【问题讨论】:
标签: c# iis configuration windows-10 makecert
它可能已安装,但它可能只是不在路径中。
例如,我可以在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 命令是尝试查找副本位置的便捷方法。在这里,我将搜索限制在 SDKs 目录中,但您可以根据需要搜索整个硬盘:
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 Personal/Certificates folder to Trusted Root Certification Authorities/Certificates.
这些命令还解决了 Google Chrome 稍后返回的错误 ERR_CERT_WEAK_SIGNATURE_ALGORITHM,因为证书是使用 SHA1 而不是 SHA256 创建的
【讨论】:
New-SelfSignedCertificate 需要 PowerShell v.4 或更高版本(相当于开箱即用的 Windows v8.1 / Windows Server 2012 R2 或更高版本)。
这就是我安装 makecert.exe 文件的方式
(注意:我先安装了Windows 10 SDK,但是这个版本没有在“bin”目录下安装makecert.exe,没问题!)
【讨论】:
10.0.18362.0 套件中。
如果您安装了 Fiddler,Fiddler 也会附带 makecert.exe。它位于
C:\Users\<yourwindowslogin>\AppData\Local\Programs\Fiddler\makecert.exe
【讨论】:
我知道现在为时已晚,但我通过安装旧的 Windows 10 SDK 版本解决了这个问题:
【讨论】:
我只是下载这个文件并将它移动到 c:/winwdows/system32
然后在命令提示符下运行我的命令:
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 加密提供程序" -sy 12
【讨论】: