共用方式為


IIS 用戶端憑證對應驗證 < iisClientCertificateMappingAuthentication>

概觀

專案的 <iisClientCertificateMappingAuthentication> 元素 <authentication> 會使用 IIS 指定用戶端憑證對應驗證的設定。

使用 IIS 對應用戶端憑證的方法有兩種不同的方法:

  • 一對一對應 - 這些對應會比對個別用戶端憑證與個別使用者帳戶一對一;每個用戶端憑證都會對應至使用者帳戶。
  • 多對一對應 - 這些對應會根據用戶端憑證中的子欄位,比對多個憑證與使用者帳戶。

注意

使用 IIS 的用戶端憑證對應驗證與 使用 Active Directory 的用戶端憑證對應 不同,方式如下:

  • 使用 Active Directory 的用戶端憑證對應驗證 - 這個驗證方法會要求 IIS 7 伺服器和用戶端電腦是 Active Directory 網域的成員,而且使用者帳戶會儲存在 Active Directory 中。 由於往返 Active Directory 伺服器,所以用戶端憑證對應驗證的這個方法已降低效能。
  • IIS 用戶端憑證對應驗證 - 這個驗證方法不需要 Active Directory,因此適用于獨立伺服器。 這個用戶端憑證對應驗證方法已提升效能,但需要更多設定和存取用戶端憑證,才能建立對應。

如需詳細資訊,請參閱 Microsoft TechNet 網站上的 在 IIS 7.0 中設定驗證

相容性

版本 備註
IIS 10.0 未在 IIS 10.0 中修改專案 <iisClientCertificateMappingAuthentication>
IIS 8.5 未在 IIS 8.5 中修改專案 <iisClientCertificateMappingAuthentication>
IIS 8.0 未在 IIS 8.0 中修改專案 <iisClientCertificateMappingAuthentication>
IIS 7.5 未在 IIS 7.5 中修改專案 <iisClientCertificateMappingAuthentication>
IIS 7.0 元素 <iisClientCertificateMappingAuthentication><authentication> 元素是在 IIS 7.0 中引進。
IIS 6.0 元素 <iisClientCertificateMappingAuthentication> 會取代 IIS 6.0 IIsCertMapper Metabase 物件。

安裝程式

專案 <iisClientCertificateMappingAuthentication> 無法在 IIS 7 和更新版本的預設安裝上使用。 若要安裝它,請使用下列步驟。

Windows Server 2012 或 Windows Server 2012 R2

  1. 在工作列上,按一下 [伺服器管理員]
  2. [伺服器管理員] 中,按一下 [管理] 功能表,然後按一下 [新增角色及功能]。
  3. 在 [ 新增角色及功能精 靈] 中,按 [ 下一步]。 選取安裝類型,然後按 [ 下一步]。 選取目的地伺服器,然後按 [ 下一步]。
  4. 在 [ 伺服器角色] 頁面上,依序展開 [ Web 服務器] ([IIS) ]、[ 網頁伺服器]、[ 安全性],然後選取 [ IIS 用戶端憑證對應驗證]。 按一下 [下一步] 。
    反白顯示並選取 [I I S 用戶端憑證對應驗證] 選項的螢幕擷取畫面。
  5. 在 [選取功能] 頁面上,按 [下一步]
  6. 在 [確認安裝選項] 頁面上,按一下 [安裝]
  7. 在 [結果] 頁面上,按一下 [關閉]

Windows 8 或 Windows 8.1

  1. 在 [開始] 畫面上,將指標一路移至左下角,以滑鼠右鍵按一下 [開始] 按鈕,然後按一下[主控台]。
  2. 主控台中,按一下 [程式和功能],然後按一下 [開啟或關閉 Windows 功能]。
  3. 序展開 [Internet Information Services]、[ 萬維網服務]、[ 安全性],然後選取 [IIS 用戶端憑證對應驗證]。
    反白顯示並選取 [I I S 用戶端憑證對應驗證] 資料夾的螢幕擷取畫面。
  4. 按一下 [確定]。
  5. 按一下 [關閉] 。

Windows Server 2008 或 Windows Server 2008 R2

  1. 在工作列上,按一下 [開始],指向 [系統管理工具],然後按一下[伺服器管理員]。
  2. [伺服器管理員階層] 窗格中,展開 [角色],然後按一下 [Web 服務器] (IIS)
  3. 在 [ Web Server (IIS) ] 窗格中,捲動至 [ 角色服務 ] 區段,然後按一下 [ 新增角色服務]。
  4. 在 [新增角色服務精靈] 的 [選取角色服務] 頁面上,選取[IIS 用戶端憑證對應驗證],然後按 [下一步]。
    [新增角色服務精靈] 的螢幕擷取畫面,其中已醒目提示 [I S 用戶端憑證對應驗證] 選項。
  5. 在 [確認安裝選項] 頁面上,按一下 [安裝]
  6. 在 [結果] 頁面上,按一下 [關閉]

Windows Vista 或 Windows 7

  1. 在工作列上,按一下 [開始],然後按一下[主控台]。
  2. 主控台中,按一下 [程式和功能],然後按一下[開啟或關閉 Windows 功能]。
  3. 展開 [Internet Information Services],然後選取 [IIS 用戶端憑證對應驗證],然後按一下 [ 確定]。
    展開 [安全性] 資料夾的螢幕擷取畫面,其中顯示醒目提示的 I S 用戶端憑證對應驗證資料夾。

作法

沒有用於設定 IIS 7 的 IIS 用戶端憑證對應驗證的使用者介面。 For examples of how to configure IIS Client Certificate Mapping authentication programmatically, see the Code Samples section of this document.

組態

元素 <iisClientCertificateMappingAuthentication><authentication> 元素可以在伺服器和月臺層級設定。

屬性

屬性 描述
defaultLogonDomain 選用的 String 屬性。

指定伺服器用來驗證使用者的預設網域。
enabled 選擇性的 Boolean 屬性。

指定是否啟用使用 IIS 的用戶端憑證對應驗證。

預設值為 false
logonMethod 選擇性列舉屬性。

logonMethod屬性可以是下列其中一個可能的值。 (如需這些值的詳細資訊,請參閱 LogonUser.)

預設值為 ClearText
描述
Batch 此登入類型適用于批次伺服器,其中進程可能代表使用者執行,而不需要直接介入。

數值為 1
ClearText 此登入類型會保留驗證套件中的名稱和密碼,這可讓伺服器在模擬用戶端時連線到其他網路伺服器。

數值為 3
Interactive 此登入類型適用于將以互動方式使用電腦的使用者。

數值為 0
Network 此登入類型適用于高效能伺服器,以驗證純文字密碼。 此登入類型不會快取認證。

數值為 2
manyToOneCertificateMappingsEnabled 選擇性的 Boolean 屬性。

指定是否啟用多對一對應

預設值是 true
oneToOneCertificateMappingsEnabled 選擇性的 Boolean 屬性。

指定是否啟用一對一對應

預設值是 true

子元素

元素 描述
manyToOneMappings 選擇性項目。

將用戶端憑證對應至一組萬用字元準則,以驗證憑證並指派使用者帳戶。
oneToOneMappings 選擇性項目。

指定一對一用戶端憑證對應。

組態範例

下列組態範例會針對預設網站執行下列動作:

  • 使用多對一憑證對應啟用 IIS 用戶端憑證對應驗證。
  • 根據符合 Contoso 之用戶端憑證主體中的組織欄位,為使用者帳戶建立多對一憑證對應規則。
  • 設定月臺以要求 SSL 並交涉用戶端憑證。
<location path="Default Web Site">
   <system.webServer>
      <security>
         <authentication>
            <windowsAuthentication enabled="false" />
            <anonymousAuthentication enabled="false" />
            <digestAuthentication enabled="false" />
            <basicAuthentication enabled="false" />
            <iisClientCertificateMappingAuthentication enabled="true"
                  manyToOneCertificateMappingsEnabled="true">
               <manyToOneMappings>
                  <add name="Contoso Employees"
                        enabled="true"
                        permissionMode="Allow"
                        userName="Username"
                        password="[enc:AesProvider:57686f6120447564652c2049495320526f636b73:enc]">
                     <rules>
                        <add certificateField="Subject"
                           certificateSubField="O"
                           matchCriteria="Contoso"
                           compareCaseSensitive="true" />
                     </rules>
                  </add>
               </manyToOneMappings>
            </iisClientCertificateMappingAuthentication>
         </authentication>
         <access sslFlags="Ssl, SslNegotiateCert" />
      </security>
   </system.webServer>
</location>

下列設定範例會使用預設網站的一對一憑證對應來啟用 IIS 用戶端憑證對應驗證、為使用者帳戶建立單對一憑證對應,並設定網站要求 SSL 和交涉用戶端憑證。

<location path="Default Web Site">
   <system.webServer>
      <security>
         <access sslFlags="Ssl, SslNegotiateCert" />
         <authentication>
            <windowsAuthentication enabled="false" />
            <anonymousAuthentication enabled="false" />
            <digestAuthentication enabled="false" />
            <basicAuthentication enabled="false" />
            <iisClientCertificateMappingAuthentication enabled="true"
                  oneToOneCertificateMappingsEnabled="true">
               <oneToOneMappings>
                  <add enabled="true"
                     userName="administrator"
                     password="[enc:57686f6120447564652c2049495320526f636b73:enc]"
                     certificate="Base64-Encoded-Certificate-Data" />
               </oneToOneMappings>
            </iisClientCertificateMappingAuthentication>
         </authentication>
      </security>
   </system.webServer>
</location>

如何從用戶端憑證擷取 Base-64 編碼字串

注意

若要擷取本主題中所有範例的 Base-64 編碼憑證資料,您可以使用下列步驟匯出憑證:

  1. 按一下 [開始],然後按一下 [ 執行]。

  2. 輸入 MMC,然後按一下 [ 確定]。

  3. 當 Microsoft Management Console 開啟時,按一下 [ 檔案],然後按一下 [ 新增/移除嵌入式管理單元]。

  4. 在 [ 新增或移除嵌入式管理單元] 對話方塊中:

    • 醒目提示可用嵌入式管理單元清單中的 [憑證 ],然後按一下 [ 新增]。
    • 選擇管理 [我的使用者帳戶] 的憑證,然後按一下 [ 完成]。
    • 按一下 [確定] ,關閉對話方塊。
  5. 在 Microsoft Management Console 中:

    • 展開 [憑證 - 目前使用者]、[ 個人] 和 [ 憑證]。
    • 在憑證清單中,以滑鼠右鍵按一下您要匯出的憑證,然後按一下 [ 所有工作],然後按一下 [ 匯出]。
  6. 當 [ 憑證匯出精靈 ] 開啟時:

    • 按一下 [下一步] 。
    • 選擇 [否],不要匯出私密金鑰,然後按 [ 下一步]。
    • 選擇 Base-64 編碼的 X.509 9 (。CER) 匯出格式,然後按 [下一步]。
    • 選擇將憑證儲存到桌面作為 MyCertificate.cer,然後按 [ 下一步]。
    • 按一下 [完成] ;您應該會看到一個對話方塊,指出匯出成功。
  7. 關閉 Microsoft Management Console。

  8. 開啟您使用 Windows 記事本匯出的 MyCertificate.cer 檔案:

    • 從文字開頭移除 「-----BEGIN CERTIFICATE-----」。
    • 從文字結尾移除 「-----END CERTIFICATE-----」。
    • 將所有行串連成單行文字 - 這是您將用於本主題中所有範例的 Base-64 編碼憑證資料。

範例程式碼

下列程式碼範例會針對預設網站執行下列動作:

  • 使用多對一憑證對應啟用 IIS 用戶端憑證對應驗證。
  • 根據符合 Contoso 之用戶端憑證主體中的組織欄位,為使用者帳戶建立多對一憑證對應規則。
  • 將月臺設定為需要 SSL,並交涉用戶端憑證。

AppCmd.exe

appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/iisClientCertificateMappingAuthentication /enabled:"True" /manyToOneCertificateMappingsEnabled:"True" /commit:apphost

appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/iisClientCertificateMappingAuthentication /+"manyToOneMappings.[name='Contoso Employees',enabled='True',permissionMode='Allow',userName='Username',password='Password']" /commit:apphost

appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/iisClientCertificateMappingAuthentication /+"manyToOneMappings.[name='Contoso Employees'].rules.[certificateField='Subject',certificateSubField='O',matchCriteria='Contoso',compareCaseSensitive='True']" /commit:apphost

appcmd.exe set config "Default Web Site" -section:system.webServer/security/access /sslFlags:"Ssl, SslNegotiateCert" /commit:apphost

注意

當您使用AppCmd.exe設定這些設定時,請務必將 認可 參數 apphost 設定為 。 這會將組態設定認可至ApplicationHost.config檔案中適當的位置區段。

C#

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 iisClientCertificateMappingAuthenticationSection = config.GetSection("system.webServer/security/authentication/iisClientCertificateMappingAuthentication", "Default Web Site");
         iisClientCertificateMappingAuthenticationSection["enabled"] = true;
         iisClientCertificateMappingAuthenticationSection["manyToOneCertificateMappingsEnabled"] = true;

         ConfigurationElementCollection manyToOneMappingsCollection = iisClientCertificateMappingAuthenticationSection.GetCollection("manyToOneMappings");
         ConfigurationElement addElement = manyToOneMappingsCollection.CreateElement("add");
         addElement["name"] = @"Contoso Employees";
         addElement["enabled"] = true;
         addElement["permissionMode"] = @"Allow";
         addElement["userName"] = @"Username";
         addElement["password"] = @"Password";

         ConfigurationElementCollection rulesCollection = addElement.GetCollection("rules");
         ConfigurationElement addElement1 = rulesCollection.CreateElement("add");
         addElement1["certificateField"] = @"Subject";
         addElement1["certificateSubField"] = @"O";
         addElement1["matchCriteria"] = @"Contoso";
         addElement1["compareCaseSensitive"] = true;
         rulesCollection.Add(addElement1);
         manyToOneMappingsCollection.Add(addElement);

         ConfigurationSection accessSection = config.GetSection("system.webServer/security/access", "Default Web Site");
         accessSection["sslFlags"] = @"Ssl, SslNegotiateCert";

         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 iisClientCertificateMappingAuthenticationSection As ConfigurationSection = config.GetSection("system.webServer/security/authentication/iisClientCertificateMappingAuthentication", "Default Web Site")
      iisClientCertificateMappingAuthenticationSection("enabled") = True
      iisClientCertificateMappingAuthenticationSection("manyToOneCertificateMappingsEnabled") = True

      Dim manyToOneMappingsCollection As ConfigurationElementCollection = iisClientCertificateMappingAuthenticationSection.GetCollection("manyToOneMappings")
      Dim addElement As ConfigurationElement = manyToOneMappingsCollection.CreateElement("add")
      addElement("name") = "Contoso Employees"
      addElement("enabled") = True
      addElement("permissionMode") = "Allow"
      addElement("userName") = "Username"
      addElement("password") = "Password"

      Dim rulesCollection As ConfigurationElementCollection = addElement.GetCollection("rules")
      Dim addElement1 As ConfigurationElement = rulesCollection.CreateElement("add")
      addElement1("certificateField") = "Subject"
      addElement1("certificateSubField") = "O"
      addElement1("matchCriteria") = "Contoso"
      addElement1("compareCaseSensitive") = True
      rulesCollection.Add(addElement1)
      manyToOneMappingsCollection.Add(addElement)

      Dim accessSection As ConfigurationSection = config.GetSection("system.webServer/security/access", "Default Web Site")
      accessSection("sslFlags") = "Ssl, SslNegotiateCert"

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";

var iisClientCertificateMappingAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/iisClientCertificateMappingAuthentication", "MACHINE/WEBROOT/APPHOST/Default Web Site");
iisClientCertificateMappingAuthenticationSection.Properties.Item("enabled").Value = true;
iisClientCertificateMappingAuthenticationSection.Properties.Item("manyToOneCertificateMappingsEnabled").Value = true;

var manyToOneMappingsCollection = iisClientCertificateMappingAuthenticationSection.ChildElements.Item("manyToOneMappings").Collection;
var addElement = manyToOneMappingsCollection.CreateNewElement("add");
addElement.Properties.Item("name").Value = "Contoso Employees";
addElement.Properties.Item("enabled").Value = true;
addElement.Properties.Item("permissionMode").Value = "Allow";
addElement.Properties.Item("userName").Value = "Username";
addElement.Properties.Item("password").Value = "Password";

var rulesCollection = addElement.ChildElements.Item("rules").Collection;
var addElement1 = rulesCollection.CreateNewElement("add");
addElement1.Properties.Item("certificateField").Value = "Subject";
addElement1.Properties.Item("certificateSubField").Value = "O";
addElement1.Properties.Item("matchCriteria").Value = "Contoso";
addElement1.Properties.Item("compareCaseSensitive").Value = true;
rulesCollection.AddElement(addElement1);
manyToOneMappingsCollection.AddElement(addElement);

var accessSection = adminManager.GetAdminSection("system.webServer/security/access", "MACHINE/WEBROOT/APPHOST/Default Web Site");
accessSection.Properties.Item("sslFlags").Value = "Ssl, SslNegotiateCert";

adminManager.CommitChanges();

VBScript

Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"

Set iisClientCertificateMappingAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/iisClientCertificateMappingAuthentication", "MACHINE/WEBROOT/APPHOST/Default Web Site")
iisClientCertificateMappingAuthenticationSection.Properties.Item("enabled").Value = True
iisClientCertificateMappingAuthenticationSection.Properties.Item("manyToOneCertificateMappingsEnabled").Value = True

Set manyToOneMappingsCollection = iisClientCertificateMappingAuthenticationSection.ChildElements.Item("manyToOneMappings").Collection
Set addElement = manyToOneMappingsCollection.CreateNewElement("add")
addElement.Properties.Item("name").Value = "Contoso Employees"
addElement.Properties.Item("enabled").Value = True
addElement.Properties.Item("permissionMode").Value = "Allow"
addElement.Properties.Item("userName").Value = "Username"
addElement.Properties.Item("password").Value = "Password"

Set rulesCollection = addElement.ChildElements.Item("rules").Collection
Set addElement1 = rulesCollection.CreateNewElement("add")
addElement1.Properties.Item("certificateField").Value = "Subject"
addElement1.Properties.Item("certificateSubField").Value = "O"
addElement1.Properties.Item("matchCriteria").Value = "Contoso"
addElement1.Properties.Item("compareCaseSensitive").Value = True
rulesCollection.AddElement(addElement1)
manyToOneMappingsCollection.AddElement(addElement)

Set accessSection = adminManager.GetAdminSection("system.webServer/security/access", "MACHINE/WEBROOT/APPHOST/Default Web Site")
accessSection.Properties.Item("sslFlags").Value = "Ssl, SslNegotiateCert"

adminManager.CommitChanges()

下列程式碼範例會使用預設網站的一對一憑證對應來啟用 IIS 用戶端憑證對應驗證、建立使用者帳戶的單一對一憑證對應,以及設定網站以要求 SSL 和交涉用戶端憑證。

注意

若要擷取下列程式碼範例的 Base-64 編碼憑證資料,您可以使用本檔的 [設定 詳細 資料] 區段中所列的步驟匯出憑證。

AppCmd.exe

注意

由於AppCmd.exe無法剖析的憑證字串中的字元,因此您不應該使用AppCmd.exe來設定 IIS 一對一憑證對應。

C#

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 iisClientCertificateMappingAuthenticationSection = config.GetSection("system.webServer/security/authentication/iisClientCertificateMappingAuthentication", "Default Web Site");
         iisClientCertificateMappingAuthenticationSection["enabled"] = true;
         iisClientCertificateMappingAuthenticationSection["oneToOneCertificateMappingsEnabled"] = true;

         ConfigurationElementCollection oneToOneMappingsCollection = iisClientCertificateMappingAuthenticationSection.GetCollection("oneToOneMappings");
         ConfigurationElement addElement = oneToOneMappingsCollection.CreateElement("add");
         addElement["enabled"] = true;
         addElement["userName"] = @"Username";
         addElement["password"] = @"Password";
         addElement["certificate"] = @"Base-64-Encoded-Certificate-Data";
         oneToOneMappingsCollection.Add(addElement);

         ConfigurationSection accessSection = config.GetSection("system.webServer/security/access", "Default Web Site");
         accessSection["sslFlags"] = @"Ssl, SslNegotiateCert";

         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 iisClientCertificateMappingAuthenticationSection As ConfigurationSection = config.GetSection("system.webServer/security/authentication/iisClientCertificateMappingAuthentication", "Default Web Site")
      iisClientCertificateMappingAuthenticationSection("enabled") = True
      iisClientCertificateMappingAuthenticationSection("oneToOneCertificateMappingsEnabled") = True

      Dim oneToOneMappingsCollection As ConfigurationElementCollection = iisClientCertificateMappingAuthenticationSection.GetCollection("oneToOneMappings")
      Dim addElement As ConfigurationElement = oneToOneMappingsCollection.CreateElement("add")
      addElement("enabled") = True
      addElement("userName") = "Username"
      addElement("password") = "Password"
      addElement("certificate") = "Base-64-Encoded-Certificate-Data"
      oneToOneMappingsCollection.Add(addElement)

      Dim accessSection As ConfigurationSection = config.GetSection("system.webServer/security/access", "Default Web Site")
      accessSection("sslFlags") = "Ssl, SslNegotiateCert"

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";

var iisClientCertificateMappingAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/iisClientCertificateMappingAuthentication", "MACHINE/WEBROOT/APPHOST/Default Web Site");
iisClientCertificateMappingAuthenticationSection.Properties.Item("enabled").Value = true;
iisClientCertificateMappingAuthenticationSection.Properties.Item("oneToOneCertificateMappingsEnabled").Value = true;

var oneToOneMappingsCollection = iisClientCertificateMappingAuthenticationSection.ChildElements.Item("oneToOneMappings").Collection;
var addElement = oneToOneMappingsCollection.CreateNewElement("add");
addElement.Properties.Item("enabled").Value = true;
addElement.Properties.Item("userName").Value = "Username";
addElement.Properties.Item("password").Value = "Password";
addElement.Properties.Item("certificate").Value = "Base-64-Encoded-Certificate-Data";
oneToOneMappingsCollection.AddElement(addElement);

var accessSection = adminManager.GetAdminSection("system.webServer/security/access", "MACHINE/WEBROOT/APPHOST/Default Web Site");
accessSection.Properties.Item("sslFlags").Value = "Ssl, SslNegotiateCert";

adminManager.CommitChanges();

VBScript

Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"

Set iisClientCertificateMappingAuthenticationSection = adminManager.GetAdminSection("system.webServer/security/authentication/iisClientCertificateMappingAuthentication", "MACHINE/WEBROOT/APPHOST/Default Web Site")
iisClientCertificateMappingAuthenticationSection.Properties.Item("enabled").Value = True
iisClientCertificateMappingAuthenticationSection.Properties.Item("oneToOneCertificateMappingsEnabled").Value = True

Set oneToOneMappingsCollection = iisClientCertificateMappingAuthenticationSection.ChildElements.Item("oneToOneMappings").Collection
Set addElement = oneToOneMappingsCollection.CreateNewElement("add")
addElement.Properties.Item("enabled").Value = True
addElement.Properties.Item("userName").Value = "Username"
addElement.Properties.Item("password").Value = "Password"
addElement.Properties.Item("certificate").Value = "Base-64-Encoded-Certificate-Data"
oneToOneMappingsCollection.AddElement(addElement)

Set accessSection = adminManager.GetAdminSection("system.webServer/security/access", "MACHINE/WEBROOT/APPHOST/Default Web Site")
accessSection.Properties.Item("sslFlags").Value = "Ssl, SslNegotiateCert"

adminManager.CommitChanges()