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 <iisClientCertificateMappingAuthentication> 요소가 IIS 10.0에서 수정되지 않았습니다.
IIS 8.5 <iisClientCertificateMappingAuthentication> 요소가 IIS 8.5에서 수정되지 않았습니다.
IIS 8.0 <iisClientCertificateMappingAuthentication> 요소가 IIS 8.0에서 수정되지 않았습니다.
IIS 7.5 <iisClientCertificateMappingAuthentication> 요소가 IIS 7.5에서 수정되지 않았습니다.
IIS 7.0 <iisClientCertificateMappingAuthentication> 요소의 <authentication> 요소는 IIS 7.0에서 도입되었습니다.
IIS 6.0 요소는 <iisClientCertificateMappingAuthentication> IIS 6.0 IIsCertMapper 메타베이스 개체를 대체합니다.

설치 프로그램

<iisClientCertificateMappingAuthentication> IIS 7 이상의 기본 설치에서는 요소를 사용할 수 없습니다. 설치하려면 다음 단계를 사용합니다.

Windows Server 2012 또는 Windows Server 2012 R2

  1. 작업 표시줄에서 서버 관리자를 클릭합니다.
  2. 서버 관리자관리 메뉴를 클릭한 다음 역할 및 기능 추가를 클릭합니다.
  3. 역할 및 기능 추가 마법사에서 다음을 클릭합니다. 설치 유형을 선택하고 다음을 클릭합니다. 대상 서버를 선택하고 다음을 클릭합니다.
  4. 서버 역할 페이지에서 웹 서버(IIS)를 확장하고, 웹 서버를 확장하고, 보안을 확장한 다음, IIS 클라이언트 인증서 매핑 인증을 선택합니다. 다음을 클릭합니다.
    강조 표시되고 선택되는 IS 클라이언트 인증서 매핑 인증 옵션의 스크린샷
  5. 기능 선택 페이지에서 다음을 클릭합니다.
  6. 설치 선택 확인 페이지에서 설치를 클릭합니다.
  7. Results(결과) 페이지에서 Close(닫기)를 클릭합니다.

Windows 8 또는 Windows 8.1

  1. 시작 화면에서 포인터를 왼쪽 아래 모서리로 이동하고 시작 단추를 마우스 오른쪽 단추로 클릭한 다음 제어판 클릭합니다.
  2. 제어판프로그램 및 기능을 클릭한 다음 Windows 기능 켜기 또는 끄기를 클릭합니다.
  3. 인터넷 정보 서비스를 확장하고 World Wide Web Services를 확장한 다음 보안을 확장한 다음 IIS 클라이언트 인증서 매핑 인증을 선택합니다.
    강조 표시되고 선택되는 IS 클라이언트 인증서 매핑 인증 폴더의 스크린샷
  4. 확인을 클릭합니다.
  5. 닫기를 클릭합니다.

Windows Server 2008 또는 Windows Server 2008 R2

  1. 작업 표시줄에서 시작을 클릭하고 관리 도구를 가리킨 다음 서버 관리자 클릭합니다.
  2. 서버 관리자 계층 창에서 역할을 확장한 다음 웹 서버(IIS)를 클릭합니다.
  3. 웹 서버(IIS) 창에서 역할 서비스 섹션으로 스크롤한 다음 역할 서비스 추가를 클릭합니다.
  4. 역할 서비스 추가 마법사역할 서비스 선택 페이지에서 IIS 클라이언트 인증서 매핑 인증을 선택하고 다음을 클릭합니다.
    IS 클라이언트 인증서 매핑 인증 옵션이 강조 표시된 역할 서비스 추가 마법사의 스크린샷
  5. 설치 선택 확인 페이지에서 설치를 클릭합니다.
  6. Results(결과) 페이지에서 Close(닫기)를 클릭합니다.

Windows Vista 또는 Windows 7

  1. 작업 표시줄에서 시작을 클릭한 다음 제어판 클릭합니다.
  2. 제어판프로그램 및 기능을 클릭한 다음 Windows 기능 켜기 또는 끄기를 클릭합니다.
  3. 인터넷 정보 서비스를 확장한 다음 IIS 클라이언트 인증서 매핑 인증을 선택한 다음 확인을 클릭합니다.
    강조 표시된 IS 클라이언트 인증서 매핑 인증 폴더를 보여 주는 확장 중인 보안 폴더의 스크린샷

방법

IIS 7에 대한 IIS 클라이언트 인증서 매핑 인증을 구성하기 위한 사용자 인터페이스가 없습니다. IIS 클라이언트 인증서 매핑 인증을 프로그래밍 방식으로 구성하는 방법에 대한 예제는 이 문서의 코드 샘플 섹션을 참조하세요.

구성

<iisClientCertificateMappingAuthentication> 요소의 <authentication> 요소는 서버 및 사이트 수준에서 구성할 수 있습니다.

특성

attribute Description
defaultLogonDomain 선택적 문자열 특성입니다.

서버에서 사용자를 인증하는 데 사용하는 기본 도메인을 지정합니다.
enabled 선택적 부울 특성입니다.

IIS를 사용하여 클라이언트 인증서 매핑 인증을 사용할지 여부를 지정합니다.

기본값은 false입니다.
logonMethod 선택적 열거형 특성입니다.

logonMethod 특성은 다음과 같은 가능한 값 중 하나일 수 있습니다. (이러한 값에 대한 자세한 내용은 LogonUser를 참조하세요.)

기본값은 ClearText입니다.
Description
Batch 이 로그온 유형은 직접 개입 없이 사용자를 대신하여 프로세스가 실행될 수 있는 일괄 처리 서버용입니다.

숫자 값은 입니다 1.
ClearText 이 로그온 유형은 인증 패키지의 이름과 암호를 유지하므로 서버가 클라이언트를 가장하는 동안 다른 네트워크 서버에 연결할 수 있습니다.

숫자 값은 입니다 3.
Interactive 이 로그온 유형은 대화형으로 컴퓨터를 사용하는 사용자를 위한 것입니다.

숫자 값은 입니다 0.
Network 이 로그온 유형은 고성능 서버가 일반 텍스트 암호를 인증하기 위한 것입니다. 이 로그온 유형에 대한 자격 증명은 캐시되지 않습니다.

숫자 값은 입니다 2.
manyToOneCertificateMappingsEnabled 선택적 부울 특성입니다.

다 대 일 매핑을 사용할 수 있는지 여부를 지정합니다.

기본값은 true입니다.
oneToOneCertificateMappingsEnabled 선택적 부울 특성입니다.

일대일 매핑을 사용할지 여부를 지정합니다.

기본값은 true입니다.

자식 요소

요소 Description
manyToOneMappings 선택적 요소입니다.

클라이언트 인증서를 인증서를 인증하고 사용자 계정을 할당하는 와일드카드 조건 집합에 매핑합니다.
oneToOneMappings 선택적 요소입니다.

일대일 클라이언트 인증서 매핑을 지정합니다.

구성 샘플

다음 구성 샘플은 기본 웹 사이트에 대해 다음 작업을 수행합니다.

  • 다대일 인증서 매핑을 사용하여 IIS 클라이언트 인증서 매핑 인증을 사용하도록 설정합니다.
  • Contoso와 일치하는 클라이언트 인증서의 주체에 있는 organization 필드를 기반으로 사용자 계정에 대한 다대일 인증서 매핑 규칙을 만듭니다.
  • 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 관리 콘솔이 열리면 파일을 클릭한 다음 스냅인 추가/제거를 클릭합니다.

  4. 스냅인 추가 또는 제거 대화 상자에서 다음을 수행합니다.

    • 사용 가능한 스냅인 목록에서 인증서 를 강조 표시한 다음 추가를 클릭합니다.
    • 내 사용자 계정에 대한 인증서를 관리하도록 선택한 다음 마침을 클릭합니다.
    • 확인 을 클릭하여 대화 상자를 닫습니다.
  5. Microsoft 관리 콘솔에서 다음을 수행합니다.

    • 인증서 - 현재 사용자, 개인, 인증서를 차례로 확장합니다.
    • 인증서 목록에서 내보낼 인증서를 마우스 오른쪽 단추로 클릭한 다음 모든 작업을 클릭한 다음 내보내기를 클릭합니다.
  6. 인증서 내보내기 마법사가 열리면 다음을 수행합니다.

    • 다음을 클릭합니다.
    • 아니요, 프라이빗 키를 내보내지 않음을 선택한 다음, 다음을 클릭합니다.
    • Base-64로 인코딩된 X.509 9(를 선택합니다. CER) 내보내기 형식에 대해 다음을 클릭합니다.
    • 인증서를 데스크톱에 MyCertificate.cer로 저장하도록 선택한 다음, 다음을 클릭합니다.
    • 마침을 클릭합니다. 내보내기 성공이라는 대화 상자가 표시됩니다.
  7. Microsoft Management Console을 닫습니다.

  8. Windows 메모장을 사용하여 내보낸 MyCertificate.cer 파일을 엽니다.

    • 텍스트의 시작에서 "-----BEGIN CERTIFICATE-----"를 제거합니다.
    • 텍스트 끝에서 "인증서---------- 보내기"를 제거합니다.
    • 모든 줄을 한 줄의 텍스트로 연결 - 이 항목의 모든 샘플에 사용할 Base-64로 인코딩된 인증서 데이터입니다.

샘플 코드

다음 코드 샘플은 기본 웹 사이트에 대해 다음 작업을 수행합니다.

  • 다대일 인증서 매핑을 사용하여 IIS 클라이언트 인증서 매핑 인증을 사용하도록 설정합니다.
  • Contoso와 일치하는 클라이언트 인증서의 주체에 있는 organization 필드를 기반으로 사용자 계정에 대한 다대일 인증서 매핑 규칙을 만듭니다.
  • 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()