在 Exchange 2016 中配置基于证书的身份验证

Exchange 中基于证书的身份验证 (CBA) 允许使用客户端证书(而不是输入用户名和密码)Outlook 网页版 ((以前称为 Outlook Web App) 和 Exchange ActiveSync 客户端)进行身份验证。

配置 Exchange 前,需要向每个用户颁发客户端证书。 由于所涉及的证书数量众多,因此应使用自动内部公钥基础结构 (PKI) 来颁发和管理客户端证书。 例如,Active Directory 证书服务 (AD CS) 就是自动内部 PKI。 有关 AD CS 的详细信息,请参阅 Active Directory 证书服务概述。 下面详细介绍了证书要求:

  • The client certificate must be issued for client authentication (for example, the default User certificate template in AD CS).

  • 客户端证书必须包含用户的用户主体名称 (UPN)(具体位于证书的 SubjectSubject Alternative Name 字段中)。

  • 客户端证书必须与 Active Directory 中的用户帐户相关联。

  • 访问 Web 上的 Outlook和 ActiveSync 所涉及的全部服务器和设备(包括代理服务器和客户端设备)都必须信任客户端证书的整个信任链(证书颁发机构的根证书,以及用于颁发证书的任何中间 CA)。

对于 Web 上的 Outlook中的 CBA,客户端证书必须安装在本地计算机、设备或智能卡上。 对于 ActiveSync 中的 CBA,客户端证书必须安装在本地设备上。 可以使用 Intune 等移动设备管理 (MDM) 解决方案,在设备上自动安装证书。 有关 Intune 的详细信息,请参阅 Microsoft Intune 概述

开始前,有必要了解什么?

提示

是否有任何疑问? 请在 Exchange 论坛中寻求帮助。 请访问以下论坛:Exchange ServerExchange OnlineExchange Online Protection

第 1 步:使用 Exchange 命令行管理程序在所有 Exchange 服务器上安装客户端证书映射身份验证功能

共用同一命名空间和 URL 的所有 Exchange 服务器都必须使用相同的身份验证方法。 必须在所有 Exchange 服务器上安装客户端证书映射身份验证功能。

在 Exchange 命令行管理程序中,运行以下命令:

Install-WindowsFeature Web-Client-Auth

若要详细了解语法和参数,请参阅 Install-WindowsFeature

第 2 步:使用 IIS Manager 为 Exchange 服务器启用 Active Directory 客户端证书身份验证

  1. 打开 Exchange 服务器上的 IIS 管理器。 在 Windows Server 2012 或更高版本中执行此操作的简便方法是按 Windows 键 + Q,键入 inetmgr,并在结果中选择" Internet Information Services (IIS) 管理器"。

  2. Select the server, and verify Features View is selected at the bottom of the page.

  3. In the IIS section, double-click Authentication.

    在 IIS 中,选择“服务器”,然后选择“身份验证”。

  4. On the Authentication page that opens, select Active Directory Client Certificate Authentication from the list, and in the Actions pane, click Enable.

    IIS 中服务器的“身份验证”页。

    此时,系统会显示警告,提醒你必须启用 SSL 才能使用 Active Directory 客户端证书映射。

步骤 3:使用 IIS 管理器配置Outlook 网页版、Exchange 管理中心和 ActiveSync 虚拟目录,以要求客户端证书

注意:需要 客户端 证书,因为 接受 客户端证书 (支持 CBA 和常规用户名和密码身份验证) 并不能在所有类型的 ActiveSync 设备中一致工作。

  1. In IIS Manager, expand the server, expand Sites, and then expand Default Web Site.

  2. Select the owa virtual directory, and verify Features View is selected at the bottom of the page.

  3. In the IIS section, double-click SSL Settings.

  4. On the SSL Settings page, verify Require SSL is checked, and select the Client certificates value Require.

  5. In the Actions pane, click Apply.

    在 IIS 中,在虚拟目录的 SSL 设置中,选择“客户端证书”下的“需要”。

  6. 选择 Microsoft-Server-ActiveSync 虚拟目录。

  7. In the IIS section, double-click SSL Settings.

  8. On the SSL Settings page, verify Require SSL is checked, and select the Client certificates value Require.

  9. In the Actions pane, click Apply.

注意:虽然可以在命令行上执行这些过程,但这些步骤可能不会配置所需的注册表项。 可以使用 IIS 管理器中的早期过程 (这肯定会) 正确设置注册表项,或者在命令行上执行过程后,需要验证注册表项 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\SslBindingInfo\0.0.0.0:443 是否设置为值 1

若要在命令行上执行这些过程,请在 Exchange 服务器上打开提升的命令提示符, (打开命令提示符窗口,方法是选择“ 以管理员身份运行 ”) 并运行以下命令:

%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site/owa/" -section:system.webserver/security/access /sslFlags:"Ssl, SslRequireCert" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site/ecp/" -section:system.webserver/security/access /sslFlags:"Ssl, SslRequireCert" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site/Microsoft-Server-ActiveSync/" -section:system.webserver/security/access /sslFlags:"Ssl, SslRequireCert" /commit:apphost

步骤 4:使用 Exchange 命令行管理程序在 Outlook 网页版、Exchange 管理中心和 ActiveSync 虚拟目录上禁用身份验证其他身份验证方法

需要客户端证书进行身份验证后,需要在 Outlook 网页版、Exchange 管理中心 (EAC) 和 ActiveSync 虚拟目录上禁用所有其他身份验证方法。 默认情况下,仅启用了基本身份验证和窗体身份验证。

  1. 在 Exchange 命令行管理程序中,将 ServerName> 替换为< Exchange 服务器的名称,并运行以下命令以禁用Outlook 网页版虚拟目录上的所有其他身份验证方法:

    Set-OwaVirtualDirectory "<ServerName>\owa (Default Web Site)" -BasicAuthentication $false -WindowsAuthentication $false -DigestAuthentication $false -FormsAuthentication $false -AdfsAuthentication $false -OAuthAuthentication $false
    

    有关语法和参数的详细信息,请参阅Set-OwaVirtualDirectory

  2. 在 Exchange 命令行管理程序中,将 ServerName> 替换为< Exchange 服务器的名称,并运行以下命令以禁用 EAC 虚拟目录上的所有其他身份验证方法:

    Set-EcpVirtualDirectory "<ServerName>\ecp (Default Web Site)" -BasicAuthentication $false -WindowsAuthentication $false -DigestAuthentication $false -FormsAuthentication $false -AdfsAuthentication $false
    

    有关语法和参数的详细信息,请参阅 Set-EcpVirtualDirectory

  3. ServerName> 替换为< Exchange 服务器的名称,并运行以下命令以禁用 ActiveSync 虚拟目录上的所有其他身份验证方法:

    Set-ActiveSyncVirtualDirectory "<ServerName>\Microsoft-Server-ActiveSync (Default Web Site)" -BasicAuthEnabled $false -WindowsAuthEnabled $false
    

    若要详细了解语法和参数,请参阅 Set-ActiveSyncVirtualDirectory

步骤 5:使用 IIS 管理器为 Outlook 网页版、Exchange 管理中心和 ActiveSync 虚拟目录启用客户端证书映射

重要

执行这一步后,运行 Set-ActiveSyncVirtualDirectory cmdlet 可能会对 ActiveSync 禁用客户端证书映射。

  1. In IIS Manager, expand the server, expand Sites, and then expand Default Web Site.

  2. Select the owa virtual directory, and verify Features View is selected at the bottom of the page.

  3. In the Management section, double-click Configuration Editor.

  4. “配置编辑器” 页上,单击 “部分”上的下拉列表,然后导航到 system.webServer>安全>身份验证>客户端CertificateMappingAuthentication

    在 IIS 中为 owa 虚拟目录选择Configuration Manager中的 clientCertificateMappingAuthentication。

  5. Set the enabled value to True, and in the Actions pane, click Apply.

    在 IIS 中的配置编辑器中为 owa 虚拟目录启用 clientCertificateMappingAuthentication 值。

  6. 选择 ecp 虚拟目录。

  7. In the Management section, double-click Configuration Editor.

  8. “配置编辑器” 页上,单击 “部分”上的下拉列表,然后导航到 system.webServer>安全>身份验证>客户端CertificateMappingAuthentication

  9. Set the enabled value to True, and in the Actions pane, click Apply.

  10. 选择 Microsoft-Server-ActiveSync 虚拟目录。

  11. In the Management section, double-click Configuration Editor.

  12. “配置编辑器” 页上,单击 “部分”上的下拉列表,然后导航到 system.webServer>安全>身份验证>客户端CertificateMappingAuthentication

  13. Set the enabled value to True, and in the Actions pane, click Apply.

注意:若要使用命令行执行这些过程,请在 Exchange 服务器上打开提升的命令提示符,然后运行以下命令:

%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site/owa/" -section:system.webserver/security/authentication/clientCertificateMappingAuthentication /enabled:"True" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site/ecp/" -section:system.webserver/security/authentication/clientCertificateMappingAuthentication /enabled:"True" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site/Microsoft-Server-ActiveSync/" -section:system.webserver/security/authentication/clientCertificateMappingAuthentication /enabled:"True" /commit:apphost

第 6 步(可选):向 Active Directory 中的 Enterprise NTAuth 存储添加第三方证书颁发机构的根证书

只有在不使用 AD CS 颁发客户端证书时,才需要执行这一步。 此设置指明可以信任证书颁发机构 (CA),它能够颁发用于 Active Directory 身份验证的客户端证书。

  1. 将 CA 的根证书导出为 Base64 编码的或 DER 二进制编码的 X.509 .cer 文件。 在此示例中,我们将使用 C:\Data\CARoot.cer.。

  2. 在任意域成员服务器上(例如,域控制器或 Exchange 服务器),打开提升的命令提示符,然后运行以下命令:

    %windir%\system32\certutil.exe -enterprise -addstore NTAuth "C:\Data\CARoot.cer"
    

    请注意,只有 企业管理员组的成员才能执行这一步。

第 7 步(可选):使用 IIS Manager 提高 Web 上的 Outlook和 ActiveSync 虚拟目录的 UploadReadAheadSize 值

如果客户端出现错误,可能需要提高 IIS 元数据库中的 uploadReadAheadSize 值,以便于使用请求头。

  1. In IIS Manager, expand the server, expand Sites, and then expand Default Web Site.

  2. Select the owa virtual directory, and verify Features View is selected at the bottom of the page.

  3. In the Management section, double-click Configuration Editor.

  4. “配置编辑器” 页上,单击 “部分”上的下拉列表,然后导航到 systemwebServer>serverRuntime

    在 IIS 中的配置编辑器中为 owa 虚拟目录选择“serverRuntime”。

  5. Set the uploadReadAheadSize value to 49152, and in the Actions pane, click Apply.

    在 IIS 中的配置编辑器中更改 owa 虚拟目录的 uploadReadAheadSize 值。

  6. 选择 ecp 虚拟目录。

  7. In the Management section, double-click Configuration Editor.

  8. “配置编辑器” 页上,单击 “部分”上的下拉列表,然后导航到 systemwebServer>serverRuntime

  9. Set the uploadReadAheadSize value to 49152, and in the Actions pane, click Apply.

  10. 选择 Microsoft-Server-ActiveSync 虚拟目录。

  11. In the Management section, double-click Configuration Editor.

  12. “配置编辑器” 页上,单击 “部分”上的下拉列表,然后导航到 systemwebServer>serverRuntime

  13. Set the uploadReadAheadSize value to 49152, and in the Actions pane, click Apply.

注意:若要使用命令行执行这些过程,请在 Exchange 服务器上打开提升的命令提示符,然后运行以下命令:

%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site/owa/" -section:system.webserver/serverRuntime /uploadReadAheadSize:49152
%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site/ecp/" -section:system.webserver/serverRuntime /uploadReadAheadSize:49152
%windir%\system32\inetsrv\appcmd.exe set config "Default Web Site/Microsoft-Server-ActiveSync/" -section:system.webserver/serverRuntime /uploadReadAheadSize:49152