该
<access>
元素允许你配置网站或应用程序是否使用客户端证书进行身份验证,并允许定义加密这些证书所需的加密强度。
该
<access>
元素包含一个
sslFlags
属性,可设置为以下值之一:
无
。 此默认设置禁用站点或应用程序的 SSL。
Ssl
。 站点或应用程序需要 SSL。
SslNegotiateCert
。 站点或应用程序接受客户端证书进行身份验证。
SslRequireCert
。 站点或应用程序需要客户端证书进行身份验证。
Ssl128
。 站点或应用程序需要 128 位 SSL 证书加密。
可以使用访问元素来配置站点、应用程序或虚拟目录以要求客户端证书。 为此,请为站点或应用程序设置 HTTPS 绑定,然后从证书颁发机构请求并接收证书 (CA) 。 证书可以是 Internet Server 证书、域服务器证书或自签名服务器证书。 请求服务器后,Internet Server 证书需要 CA 颁发服务器或服务器证书。 域服务器证书由在公司域上运行的 CA 计算机颁发,可帮助你仅控制对已安装证书的员工对内部资源的访问。 可以使用自签名证书排查第三方证书问题、远程管理 Internet Information Services (IIS) 7、在服务器与所选用户组之间创建安全专用通道,或测试依赖于 SSL 的应用程序功能。
打开
Internet Information Services (IIS) 管理器
:
如果使用 Windows Server 2012 或 Windows Server 2012 R2:
在任务栏上,单击
服务器管理器
,单击
“工具
”,然后单击“
Internet Information Services” (IIS) 管理器
。
如果使用Windows 8或Windows 8.1:
按住
Windows
键,按字母
X
,然后单击
控制面板
。
单击
“管理工具”
,然后双击“
Internet Information Services” (IIS) Manager
。
如果使用 Windows Server 2008 或 Windows Server 2008 R2:
在任务栏上,单击“
开始
”,指向
“管理工具
”,然后单击“
Internet Information Services” (IIS) 管理器
。
如果使用 Windows Vista 或 Windows 7:
在任务栏上,单击“
开始
”,然后单击
控制面板
。
双击
“管理工具”
,然后双击“
Internet Information Services” (IIS) 管理器
。
以下配置示例在ApplicationHost.config文件中包含时,需要在名为 Contoso 的网站与所有客户端浏览器之间建立 SSL 连接。
<location path="Contoso">
<system.webServer>
<security>
<access sslFlags="ssl">
</security>
</system.webServer>
</location>
以下示例使 SSL 访问名为 Contoso 的网站需要 SSL。
AppCmd.exe
appcmd.exe set config "Contoso" -section:system.webServer/security/access /sslFlags:"Ssl" /commit:apphost
在使用AppCmd.exe配置这些设置时,必须确保将 提交 参数 apphost 设置为该参数。 这会将配置设置提交到ApplicationHost.config文件中的相应位置部分。
using System;
using System.Text;
using Microsoft.Web.Administration;
internal static class Sample {
private static void Main() {
using(ServerManager serverManager = new ServerManager()) {
Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection accessSection = config.GetSection("system.webServer/security/access", "Contoso");
accessSection["sslFlags"] = @"Ssl";
serverManager.CommitChanges();
VB.NET
Imports System
Imports System.Text
Imports Microsoft.Web.Administration
Module Sample
Sub Main()
Dim serverManager As ServerManager = New ServerManager
Dim config As Configuration = serverManager.GetApplicationHostConfiguration
Dim accessSection As ConfigurationSection = config.GetSection("system.webServer/security/access", "Contoso")
accessSection("sslFlags") = "Ssl"
serverManager.CommitChanges()
End Sub
End Module
JavaScript
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var accessSection = adminManager.GetAdminSection("system.webServer/security/access", "MACHINE/WEBROOT/APPHOST/Contoso");
accessSection.Properties.Item("sslFlags").Value = "Ssl";
adminManager.CommitChanges();
VBScript
Set adminManager = CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set accessSection = adminManager.GetAdminSection("system.webServer/security/access", "MACHINE/WEBROOT/APPHOST/Contoso")
accessSection.Properties.Item("sslFlags").Value = "Ssl"
adminManager.CommitChanges()