一対一マッピング <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
- タスク バーで [サーバー マネージャー]をクリックします。
- [サーバー マネージャー] で、[管理] メニューを選択し、[役割と機能の追加] を選択します。
- [役割と機能の追加] ウィザードで、[次へ] をクリックします。 インストールの種類を選択し、[次へ] をクリックします。 対象サーバーを選択し、[次へ] をクリックします。
- [サーバー ロール] ページで、[Web サーバー (IIS)]、[Web サーバー] の順に展開し、[セキュリティ] を展開して、[IIS クライアント証明書マッピング認証] を選択します。 次へ をクリックします。
.
- [機能の選択] ページで、[次へ] をクリックします。
- [インストール オプションの確認] ページで、[インストール] をクリックします。
- [結果] ページで、 [閉じる]をクリックします。
Windows 8 または Windows 8.1
- [スタート] 画面で、ポインターを左下隅まで移動し、[スタート] ボタンを右クリックし、[コントロール パネル] をクリックします。
- [コントロール パネル]で [プログラムと機能] をクリックし、[Windows の機能の有効化または無効化] をクリックします。
- [インターネット インフォメーション サービス] を展開し、[World Wide Web サービス] を展開し、[セキュリティ] を展開して、[IIS クライアント証明書マッピング認証] を選択します。
- OK をクリックします。
- 閉じるをクリックします。
Windows Server 2008 または Windows Server 2008 R2
- タスク バーで [スタート] をクリックし、[管理ツール] をポイントして、[サーバー マネージャ] をクリックします。
- [サーバー マネージャ] 階層ウィンドウで [役割] を展開し、[Web サーバー (IIS)] をクリックします。
- [Web Server (IIS)] (Web サーバー (IIS)) ウィンドウで、[Role Services] (役割サービス) セクションまでスクロールし、[Add Role Services] (役割サービスの追加) をクリックします。
- 役割サービスの追加ウィザードの [役割サービスの選択] ページで、[IIS クライアント証明書マッピング認証] を選択し、[次へ] をクリックします。
- [インストール オプションの確認] ページで、[インストール] をクリックします。
- [結果] ページで、 [閉じる]をクリックします。
Windows Vista または Windows 7
- タスク バーで、[スタート]、[コントロール パネル] の順にクリックします。
- [コントロール パネル]で [プログラムと機能] をクリックし、[Turn Windows Features on or off] (Windows の機能の有効化または無効化) をクリックします。
- [インターネット インフォメーション サービス] を展開し、[IIS クライアント証明書マッピング認証] を選択し、[OK] をクリックします。
操作方法
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 でエンコードされた証明書データを取得するには、次の手順を使用して証明書をエクスポートできます。
[スタート]、[実行] の順にクリックします。
「MMC」と入力し、[OK] をクリックします。
Microsoft 管理コンソールが開いたら、[ファイル] をクリックし、[スナップインの追加と削除] をクリックします。
[スナップインの追加と削除] ダイアログ ボックスで次のように操作します。
- 使用可能なスナップインの一覧で [証明書] を強調表示し、[追加] をクリックします。
- [My user account]\(マイ ユーザー アカウント\) で証明書を管理するように選択し、[完了] をクリックします。
- [OK] をクリックしてダイアログ ボックスを閉じます。
Microsoft 管理コンソールで次のように操作します。
- [証明書 - 現在のユーザー]、[個人用]、[証明書] の順に展開します。
- 証明書の一覧で、エクスポートする証明書を右クリックし、[すべてのタスク] をクリックし、[エクスポート] をクリックします。
証明書のエクスポート ウィザードが開いたら、次の操作を行います。
- 次へ をクリックします。
- [いいえ、秘密キーをエクスポートしません] を選択し、[次へ] をクリックします。
- [Base-64 encoded X.509 9 (.CER)]\(Base-64 でエンコードされた X.509 9 (.CER)\) のエクスポート形式を選択し、[次へ] をクリックします。
- 証明書を MyCertificate.cer としてデスクトップに保存し、[次へ] をクリックします。
- [完了] をクリックすると、エクスポートが成功したことを示すダイアログ ボックスが表示されます。
Microsoft 管理コンソールを閉じます。
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()