この記事では、Microsoft インターネット インフォメーション サービス (IIS) の構成エディター機能を使用して、多対 1 のクライアント証明書マッピングを構成する方法について説明します。
元の製品バージョン: インターネット インフォメーション サービス
元の KB 番号: 2026113
はじめに
多対 1 のクライアント証明書マッピングは、ユーザー認証にクライアント証明書を使用するときに、エンド ユーザーを Windows アカウントに関連付けるために IIS によって使用されます。 ユーザーのセッションは、IIS によってこのマップされた Windows アカウントのコンテキストで実行されます。 想定どおりに動作するには、IIS で証明書とアカウントのマッピングが正しく構成されていることを確認する必要があります。
現在のバージョンの IIS では、1 対 1 または多対 1 の証明書マッピングに IIS マネージャーのユーザー インターフェイスが存在しません。 この記事では、IIS の構成エディター機能を使用して、多対 1 のクライアント証明書マッピングを構成する方法について説明します。
Note
構成エディターを使用して 1 対 1 のクライアント証明書マッピングを構成する方法については、「 一対一クライアント証明書マッピングの構成を参照してください。
IIS スキーマ
IIS の IIS クライアント証明書マッピング認証機能のスキーマを次に示します。
<sectionSchema name="system.webServer/security/authentication/iisClientCertificateMappingAuthentication">
<attribute name="enabled" type="bool" defaultValue="false" />
<attribute name="manyToOneCertificateMappingsEnabled" type="bool" defaultValue="true" />
...
<element name="manyToOneMappings">
<collection addElement="add" clearElement="clear">
<attribute name="name" type="string" required="true" isUniqueKey="true"
validationType="nonEmptyString" />
<attribute name="description" type="string" />
<attribute name="enabled" type="bool" defaultValue="true"/>
<attribute name="permissionMode" type="enum" defaultValue="Allow">
<enum name="Allow" value="1"/>
<enum name="Deny" value="2" />
</attribute>
<element name="rules">
<collection addElement="add" clearElement="clear">
<attribute name="certificateField" type="enum" required="true" isCombinedKey="true">
<enum name="Subject" value="1" />
<enum name="Issuer" value="2" />
</attribute>
<attribute name="certificateSubField" type="string" caseSensitive="true"
required="true" isCombinedKey="true" />
<attribute name="matchCriteria" type="string" caseSensitive="true"
required="true" isCombinedKey="true" />
<attribute name="compareCaseSensitive" type="bool" isCombinedKey="true" defaultValue="true" />
</collection>
</element>
<attribute name="userName" type="string" validationType="nonEmptyString" />
<attribute name="password" type="string" caseSensitive="true" encrypted="true"
defaultValue="[enc:AesProvider::enc]" />
</collection>
</element>
...
</sectionSchema>
前提条件
このチュートリアルに必要な前提条件を次に示します。
- IIS サーバーに IIS クライアント証明書マッピング モジュールがインストールされています。
- Web サイトは、Secure Sockets Layer (SSL) 接続を受け入れることができるハイパーテキスト転送プロトコル セキュア (HTTPS) バインディングで構成されます。
- クライアント証明書がクライアントにインストールされている。
構成エディターによる証明書マッピングの構成
IIS マネージャーを起動し、クライアント証明書認証用に構成する Web サイトを選択します。
Features ビューで構成エディターManagement セクションを選択します。
次の図に示すように、ドロップダウン ボックスの
system.webServer/security/authentication/iisClientCertificateMappingAuthentication
に移動します。ここには、多対一または一対一の証明書マッピングを構成するウィンドウが表示されます。 次の UI は、すべてのマッピング構成を設定できる構成エディターを通じて提供されます。
このグラフィカル ユーザー インターフェイス (GUI) を使用してプロパティを変更します。
- enabled を True に設定します。
- manyToOneCertificateMappingsEnabled を True に設定します。
- manyToOneMappings を選択し省略記号ボタンを選択して、マッピングを構成するための新しいウィンドウを起動します。
この新しいウィンドウで、選択して新しい項目を追加します。 次の図に示すように、ウィンドウ内のプロパティを変更できます。
rules の省略記号ボタンを選択すると、証明書のプロパティに基づいて一致する複数のパターンを追加できます。
これらのイメージ例では、証明書をマッピングするための規則に 2 つのエントリがあります。
まず、証明書に Subject フィールドと Issuer フィールドがあります。 次に、 matchcriteria プロパティを使用して、証明書をアカウント mydomain\testuser にマップします。
次の図では、特定の Windows アカウントの最終的なマッピングを示します。 ご覧のように、このアカウントには、 rules に 2 つのエントリがあります。
同様に、証明書のフィールド Issuer と Subject に基づいて、アカウントに対して他のマッピングを作成できます。
APPCMD.exeによる証明書マッピングの構成
これまでに説明した内容は、構成を簡単に設定するためのグラフィカル インターフェイスを提供する構成エディターを使用して実現されています。
APPCMD.exe
コマンドを使用して同じことを行うことができます。実際、構成エディターはバックグラウンドで同じことを行い、これらの設定を ApplicationHost.config ファイルに追加します。
構成エディターでは、これらのコマンドを手動で実行するオプションも提供され、UI 自体の内部からそれを実現するためのスクリプトが生成されます。
これらのコード スニペットは、証明書マッピングを構成するために同じ手順を実行します。 これらは、構成エディターの Generate Script 機能を使用して生成されました。
AppCmd コマンド
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='My 1st Mapping',description='1st User Mapping',userName='mydomain\testuser',password='abcdef']" /commit:apphost
appcmd.exe set config "Default Web Site" -section:system.webServer/security/authentication/iisClientCertificateMappingAuthentication /+"manyToOneMappings.[name='My 1st Mapping',description='1st User Mapping',userName='mydomain\testuser',password='abcdef'].rules.[certificateField='Subject',certificateSubField='CN',matchCriteria='Test User']" /commit:apphost
C# コード
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"] = @"My 1st Mapping";
addElement["description"] = @"1st User Mapping";
addElement["userName"] = @"mydomain\testuser";
addElement["password"] = @"abcdef";
ConfigurationElementCollection rulesCollection = addElement.GetCollection("rules");
ConfigurationElement addElement1 = rulesCollection.CreateElement("add");
addElement1["certificateField"] = @"Subject";
addElement1["certificateSubField"] = @"CN";
addElement1["matchCriteria"] = @"Test User";
rulesCollection.Add(addElement1);
manyToOneMappingsCollection.Add(addElement);
serverManager.CommitChanges();
}
}
}
スクリプト (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 = "My 1st Mapping";
addElement.Properties.Item("description").Value = "1st User Mapping";
addElement.Properties.Item("userName").Value = "mydomain\\testuser";
addElement.Properties.Item("password").Value = "abcdef";
var rulesCollection = addElement.ChildElements.Item("rules").Collection;
var addElement1 = rulesCollection.CreateNewElement("add");
addElement1.Properties.Item("certificateField").Value = "Subject";
addElement1.Properties.Item("certificateSubField").Value = "CN";
addElement1.Properties.Item("matchCriteria").Value = "Test User";
rulesCollection.AddElement(addElement1);
manyToOneMappingsCollection.AddElement(addElement);
adminManager.CommitChanges();