asp.net - 配置IIS客户端证书映射认证

标签 asp.net authentication iis ssl x509certificate

我正在尝试在 IIS 8、Windows Server 2012 上配置 IIS 客户端证书映射。我没有在 applicationHost.config 中看到配置,并且我尝试提供的证书未提供我的浏览器的一个选项。

这是我到目前为止尝试过的:

在 IIS 中,我创建了一个名为“PackageManager”的顶级站点:

enter image description here

SSL设置如下:

enter image description here

身份验证:启用匿名:

enter image description here

在配置编辑器中, 栏目:system.webServer/security/authentication/iisClientCertificateMappingAuthentication 来自:ApplicationHost.config <location path=’PackageManager’> 我设置了以下内容:

enter image description here

我想要 manyToOneMappings这样我就可以将证书映射到我的服务帐户(域用户):

enter image description here

我在这里创建了 2 条规则来匹配 GoDaddy 证书的主题和颁发者 CN:

enter image description here

然后我为以上所有内容生成了一个 PowerShell 脚本,如下所示:

Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'PackageManager' -filter "system.webServer/security/authentication/iisClientCertificateMappingAuthentication" -name "enabled" -value "True"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'PackageManager' -filter "system.webServer/security/authentication/iisClientCertificateMappingAuthentication" -name "defaultLogonDomain" -value "CMC"

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'PackageManager' -filter "system.webServer/security/authentication/iisClientCertificateMappingAuthentication/manyToOneMappings" -name "." -value @{name='My 1st Mapping';description='1st User Mapping';userName='DOMAIN\username';password='XXXXXXXXXXX'}

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'PackageManager' -filter "system.webServer/security/authentication/iisClientCertificateMappingAuthentication/manyToOneMappings/add[@name='My 1st Mapping']/rules" -name "." -value @{certificateField='Subject';certificateSubField='CN';matchCriteria='*.mydomain.com';compareCaseSensitive='False'}

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'PackageManager' -filter "system.webServer/security/authentication/iisClientCertificateMappingAuthentication/manyToOneMappings/add[@name='My 1st Mapping']/rules" -name "." -value @{certificateField='Issuer';certificateSubField='CN';matchCriteria='Go Daddy Secure Certificate Authority - G2';compareCaseSensitive='False'}

以上所有内容的奇怪之处在于,我在 C:\Windows\System32\inetsrv\Config\applicationHost.config 中没有看到任何对此配置的引用。

浏览此站点时,系统提示我使用证书,但 IE 没有显示我期望的证书:

enter image description here

那是我一直在试验的自签名证书。

然后我遇到了一个可爱的 403,所以我陷入了僵局。

我在配置中做错了什么,它没有出现在 applicationHost.config 中,为什么我不能选择出示我的客户端证书(它在我的商店中)?

enter image description here

最佳答案

我在 Windows Server 2012 下遇到了同样的问题,我通过在 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\Schannel 下添加两个额外的注册表项解决了这个问题:

ClientAuthTrustMode 值类型:REG_DWORD,值数据:2

SendTrustedIssuerList 值类型:REG_DWORD,值数据:0

有关详细信息,请参阅 IIS 8.5 - Mutual certificates authentication fails with error 403.16

关于asp.net - 配置IIS客户端证书映射认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29497971/

相关文章:

c# - 按 id 区分包含对象的列表

c# - 我如何根据**货币符号**(如欧元(€)等)将 123456789 转换为 1.234.567,89?

c# - 有人可以建议开发团队和 Beta 测试人员之间进行交流的在线解决方案吗

authentication - 可以对用户电子邮件进行哪些操作来防止重复

c# - 仅在部署到 IIS 后 Azure API 出现 403 错误

c# - Web 应用程序中对 System.Windows.Forms 的资源和引用

c# - 在 Linux 上将客户端证书添加到 POST 到 Kestrel REST API 的 .NET Core 无法通过服务器证书验证

node.js - Mongoose: CastError: 转换为 ObjectId 失败,路径 “me” 处的值 “_id”

c# - 部署后找不到嵌入式 Razor View (IIS)

c# - 从客户端检测到潜在危险的 Request.Path 值(?)