次の方法で共有


一対一マッピング <oneToOneMappings>

概要

<iisClientCertificateMappingAuthentication> 要素の <oneToOneMappings> 要素は、個々のクライアント証明書を個々のユーザー アカウントに一対一でマップします。 これらの一対一の証明書マッピングは、Windows 認証基本認証など、より一般的に使用される認証方法の代わりに使用できます。

Note

一対一の証明書マッピングは、複数の証明書を 1 つのユーザー アカウントにマップできる多対一の証明書マッピングとは異なります。

互換性

バージョン メモ
IIS 10.0 <oneToOneMappings> 要素は、IIS 10.0 では変更されませんでした。
IIS 8.5 <oneToOneMappings> 要素は、IIS 8.5 では変更されませんでした。
IIS 8.0 <oneToOneMappings> 要素は IIS 8.0 では変更されませんでした。
IIS 7.5 <oneToOneMappings> 要素は、IIS 7.5 では変更されませんでした。
IIS 7.0 <iisClientCertificateMappingAuthentication> 要素の <oneToOneMappings> 要素が IIS 7.0 で導入されました。
IIS 6.0 <oneToOneMappings> 要素は、IIS 6.0 IIsCertMapper メタベース オブジェクトを置き換えます。

段取り

<iisClientCertificateMappingAuthentication> 要素は、IIS 7 以降の既定のインストールでは使用できません。 インストールするには、次の手順を使用します。

Windows Server 2012 または Windows Server 2012 R2

  1. タスク バーで [サーバー マネージャー]をクリックします。
  2. [サーバー マネージャー] で、[管理] メニューを選択し、[役割と機能の追加] を選択します。
  3. [役割と機能の追加] ウィザードで、[次へ] をクリックします。 インストールの種類を選択し、[次へ] をクリックします。 対象サーバーを選択し、[次へ] をクリックします。
  4. [サーバー ロール] ページで、[Web サーバー (IIS)][Web サーバー] の順に展開し、[セキュリティ] を展開して、[IIS クライアント証明書マッピング認証] を選択します。 次へ をクリックします。
    Windows Server 2012 で選択されている I S クライアント証明書マッピング認証を示すスクリーンショット。 .
  5. [機能の選択] ページで、[次へ] をクリックします。
  6. [インストール オプションの確認] ページで、[インストール] をクリックします。
  7. [結果] ページで、 [閉じる]をクリックします。

Windows 8 または Windows 8.1

  1. [スタート] 画面で、ポインターを左下隅まで移動し、[スタート] ボタンを右クリックし、[コントロール パネル] をクリックします。
  2. [コントロール パネル][プログラムと機能] をクリックし、[Windows の機能の有効化または無効化] をクリックします。
  3. [インターネット インフォメーション サービス] を展開し、[World Wide Web サービス] を展開し、[セキュリティ] を展開して、[IIS クライアント証明書マッピング認証] を選択します。
    Windows 8 で選択されている I S クライアント証明書マッピング認証を示すスクリーンショット。
  4. OK をクリックします。
  5. 閉じるをクリックします。

Windows Server 2008 または Windows Server 2008 R2

  1. タスク バーで [スタート] をクリックし、[管理ツール] をポイントして、[サーバー マネージャ] をクリックします。
  2. [サーバー マネージャ] 階層ウィンドウで [役割] を展開し、[Web サーバー (IIS)] をクリックします。
  3. [Web Server (IIS)] (Web サーバー (IIS)) ウィンドウで、[Role Services] (役割サービス) セクションまでスクロールし、[Add Role Services] (役割サービスの追加) をクリックします。
  4. 役割サービスの追加ウィザード[役割サービスの選択] ページで、[IIS クライアント証明書マッピング認証] を選択し、[次へ] をクリックします。
    Windows Server 2008 で選択されている I S クライアント証明書マッピング認証を示すスクリーンショット。
  5. [インストール オプションの確認] ページで、[インストール] をクリックします。
  6. [結果] ページで、 [閉じる]をクリックします。

Windows Vista または Windows 7

  1. タスク バーで、[スタート][コントロール パネル] の順にクリックします。
  2. [コントロール パネル][プログラムと機能] をクリックし、[Turn Windows Features on or off] (Windows の機能の有効化または無効化) をクリックします。
  3. [インターネット インフォメーション サービス] を展開し、[IIS クライアント証明書マッピング認証] を選択し、[OK] をクリックします。
    Windows Vista または Windows 7 で選択されている I S クライアント証明書マッピング認証を示すスクリーンショット。

操作方法

IIS 7 の IIS クライアント証明書マッピング認証を構成するためのユーザー インターフェイスはありません。 IIS クライアント証明書マッピング認証をプログラムで構成する方法の例については、このドキュメントの「コード サンプル」セクションを参照してください。

構成

属性

なし。

子要素

要素 説明
add 省略可能な要素です。

一対一マッピングのコレクションに一対一のマッピングを追加します。
clear 省略可能な要素です。

一対一マッピングのコレクションから一対一マッピングへのすべての参照を削除します。

構成サンプル

次の構成サンプルでは、既定の Web サイトに対して一対一の証明書マッピングを使用して 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 でエンコードされた文字列を取得する方法

Note

このトピックのすべてのサンプルの Base-64 でエンコードされた証明書データを取得するには、次の手順を使用して証明書をエクスポートできます。

  1. [スタート][実行] の順にクリックします。

  2. 「MMC」と入力し、[OK] をクリックします。

  3. Microsoft 管理コンソールが開いたら、[ファイル] をクリックし、[スナップインの追加と削除] をクリックします。

  4. [スナップインの追加と削除] ダイアログ ボックスで次のように操作します。

    • 使用可能なスナップインの一覧で [証明書] を強調表示し、[追加] をクリックします。
    • [My user account]\(マイ ユーザー アカウント\) で証明書を管理するように選択し、[完了] をクリックします。
    • [OK] をクリックしてダイアログ ボックスを閉じます。
  5. Microsoft 管理コンソールで次のように操作します。

    • [証明書 - 現在のユーザー][個人用][証明書] の順に展開します。
    • 証明書の一覧で、エクスポートする証明書を右クリックし、[すべてのタスク] をクリックし、[エクスポート] をクリックします。
  6. 証明書のエクスポート ウィザードが開いたら、次の操作を行います。

    • 次へ をクリックします。
    • [いいえ、秘密キーをエクスポートしません] を選択し、[次へ] をクリックします。
    • [Base-64 encoded X.509 9 (.CER)]\(Base-64 でエンコードされた X.509 9 (.CER)\) のエクスポート形式を選択し、[次へ] をクリックします。
    • 証明書を MyCertificate.cer としてデスクトップに保存し、[次へ] をクリックします。
    • [完了] をクリックすると、エクスポートが成功したことを示すダイアログ ボックスが表示されます。
  7. Microsoft 管理コンソールを閉じます。

  8. Windows のメモ帳を使用してエクスポートした MyCertificate.cer ファイルを開きます。

    • テキストの先頭から "-----BEGIN CERTIFICATE-----" を削除します。
    • テキストの末尾から "-----END CERTIFICATE-----" を削除します。
    • すべての行を 1 行のテキストに連結します。これは、このトピックのすべてのサンプルで使用する Base-64 でエンコードされた証明書データです。

サンプル コード

次のコード サンプルでは、既定の Web サイトに対して一対一の証明書マッピングを使用して IIS クライアント証明書マッピング認証を有効にし、ユーザー アカウントに対して一対一の証明書マッピングを作成し、SSL を要求し、クライアント証明書をネゴシエートするようにサイトを構成します。

Note

以下に示すコード サンプルの Base-64 でエンコードされた証明書データを取得するには、このドキュメントの「構成の詳細」セクションに記載されている手順を使用して証明書をエクスポートできます。

AppCmd.exe

Note

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()