Windows 7 如何创建用于通过SSL进行双向身份验证的本地测试的客户端证书?

Windows 7 如何创建用于通过SSL进行双向身份验证的本地测试的客户端证书?,windows-7,iis-7,ssl-certificate,client-certificates,Windows 7,Iis 7,Ssl Certificate,Client Certificates,我正在尝试在IIS7上运行的web应用程序上设置双向身份验证。客户将主要是移动设备,首先我尝试使用第三代iPad运行一个演示。我想首先让它在我的工作站上运行(也运行IIS),然后通过iPad复制工作证书 然而,我碰到了一堵墙 我已经让网站通过https安全运行,并安装了自签名服务器证书,但我似乎不知道如何生成可以安装在iPad上的客户端证书。由于我在运行Windows 7的本地工作站上工作,因此无法使用通常的http://machinename/CertSvr执行此操作 因此,我想知道是否有方法

我正在尝试在IIS7上运行的web应用程序上设置双向身份验证。客户将主要是移动设备,首先我尝试使用第三代iPad运行一个演示。我想首先让它在我的工作站上运行(也运行IIS),然后通过iPad复制工作证书

然而,我碰到了一堵墙

我已经让网站通过https安全运行,并安装了自签名服务器证书,但我似乎不知道如何生成可以安装在iPad上的客户端证书。由于我在运行Windows 7的本地工作站上工作,因此无法使用通常的
http://machinename/CertSvr
执行此操作

因此,我想知道是否有方法获取
makecert
以生成测试客户端证书,或者是否可以更改服务器证书中的使用标志,使其适合在客户端上使用。或者,谷歌搜索的最后一天还没有发现什么工具

更新:

我找到了它,并一字不差地跟着它走。这一切似乎都正常工作,没有错误,最后我得到了两个pfx文件,一个用于服务器,一个用于客户端(我使用
pvk2pfx
生成了这些文件,并保留了原始的
.pvk
.cer
文件以防万一)

我在
证书(本地计算机)>受信任的根证书颁发机构下安装了服务器证书
,并在
证书(当前用户)>个人
下安装了客户端证书。我还将服务器证书(CA证书)导入IIS。当IIS被配置为接受或忽略客户端证书时,一切正常。然而,一旦它被设置为“需要”,我就会在请求站点时得到403.7。我还尝试将客户端证书导入IE/Chrome中的证书存储,但同样没有成功


有什么明显的我做错了吗

当你问这个问题时,这可能并不存在,但是微软现在有了一个解决这个问题的方法。易于遵循,并为我完美工作

在本地IIS Express上启用客户端证书:

将\YourSlnFolder\.vs\config\applicationhost.config->
更改为

键入您的密码

pvk2pfx.exe -pvk localtestclientcert.pvk -pi {password} -spc localtestclientcert.cer -pfx localtestclientcert.pfx
创建证书吊销列表(CRL)

捆绑到.pfx(pvk2pfx.exe需要为VS2017安装“使用C++进行桌面开发”)

来自根证书的客户端证书: 键入您的密码

pvk2pfx.exe -pvk localtestclientcert.pvk -pi {password} -spc localtestclientcert.cer -pfx localtestclientcert.pfx
导入证书。

启动mmc.exe

File -> Add or Remove Snap-ins -> Certificates -> Add -> Computer account -> Local computer

Certificates (Local Computer) -> Personal -> Certificates -> Right click -> All tasks -> Import -> localtestclientcert.pfx

Certificates (Local Computer) -> Trusted Root Certification Authorities -> Certificates -> Right click -> All tasks -> Import -> RootCertificate.cer
用于在浏览器中进行身份验证:

File -> Add or Remove Snap-ins -> Certificates -> Add -> My user account

Certificates - Current User -> Personal -> Certificates -> Right click -> All tasks -> Import -> localtestclientcert.pfx
现在访问您的站点需要服务器信任的客户端证书:

如果您按照本指南操作并出现如下错误:

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.

您可能需要重新启动计算机。请注意,仅关闭iisexpress进程或Visual Studio是不够的。
500.19
可以在不重新启动的情况下解决,但证书很棘手,因此建议重新启动计算机

如果出现错误
,则请求被中止:无法创建SSL/TLS安全通道
,原因可能是应用程序池无权访问特定证书


证书(本地计算机)->Personal->Certificates->localtestclientcert->右键单击->所有任务->管理私钥->添加
IIS APPPOOL\YourWebSite
,并授予其完全控制权。

没有人响应,但我最终找到了,并可以确认它一切正常工作。希望这对某人有所帮助。我刚刚为命令输入了一些密码-C:\Windows\system32>makecert-r-pe-ss my-sr LocalMachine-n“CN=YangsoftCA”-sv“YangsoftCA.pvk”YangsoftCA.cerCAUTION-请勿直接复制粘贴该代码。它有非法的/ms word双引号,这将导致命令失败。你必须用键盘打字。如果没有,则会出现错误-makecert失败-错误:CryptCertStrToNameW失败。但是,此错误还有许多其他原因。C:\Windows\system32>makecert-r-pe-ss my-sr LocalMachine-n“CN=YangsoftCA”-sv“YangsoftCA.pvk”YangsoftCA.cer在Windows 8之后,makecert包含在“Windows软件开发工具包(SDK)”和“Windows驱动程序工具包(WDK)”中。因此,您需要先安装其中一个,然后打开“针对VS2015的开发人员命令提示符”以使用makecert。链接:
makecert.exe -ic TestRootCertificate.cer -iv TestRootCertificate.pvk -pe -sv localtestclientcert.pvk -a sha1 -n "CN=localtestclientcert" -len 2048 -b 01/01/2015 -e 01/01/2030 -sky exchange localtestclientcert.cer -eku 1.3.6.1.5.5.7.3.2
pvk2pfx.exe -pvk localtestclientcert.pvk -pi {password} -spc localtestclientcert.cer -pfx localtestclientcert.pfx
File -> Add or Remove Snap-ins -> Certificates -> Add -> Computer account -> Local computer

Certificates (Local Computer) -> Personal -> Certificates -> Right click -> All tasks -> Import -> localtestclientcert.pfx

Certificates (Local Computer) -> Trusted Root Certification Authorities -> Certificates -> Right click -> All tasks -> Import -> RootCertificate.cer
File -> Add or Remove Snap-ins -> Certificates -> Add -> My user account

Certificates - Current User -> Personal -> Certificates -> Right click -> All tasks -> Import -> localtestclientcert.pfx
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
HTTP Error 403.7 - Forbidden
The page you are attempting to access requires your browser to have a Secure Sockets Layer (SSL) client certificate that the Web server recognizes.