IIS クライアント証明書マッピング認証 <iisClientCertificateMappingAuthentication>
- 概要
- 互換性
- セットアップ
- 方法
- 構成
- サンプル コード
※本ページに挿入されている画像をクリックすると、画像全体が別ウィンドウで表示されます。
<authentication>
要素の <iisClientCertificateMappingAuthentication>
要素は、IIS を使用してクライアント証明書マッピング認証の設定を指定します。
IIS を使用してクライアント証明書をマッピングする方法は 2 つあります。
- 1 対 1 マッピング - これらのマッピングは、個々のクライアント証明書を個々のユーザー アカウントに 1 対 1 で一致させます。つまり、各クライアント証明書が 1 つのユーザー アカウントにマッピングされます。
- 多対 1 マッピング - これらのマッピングでは、クライアント証明書のサブフィールドに基づいて複数の証明書を 1 つのユーザー アカウントに一致させます。
注 : IIS を使用したクライアント証明書マッピング認証と Active Directory を使用したクライアント証明書マッピング認証との相違点を次に示します。
- Active Directory を使用したクライアント証明書マッピング認証 - この認証方法の場合、IIS 7.0 サーバーおよびクライアント コンピューターが Active Directory ドメインのメンバーで、ユーザー アカウントが Active Directory に格納されている必要があります。このクライアント証明書マッピング認証方法では、Active Directory サーバーへの往復によりパフォーマンスが低下します。
- IIS クライアント証明書マッピング認証 - この認証方法では Active Directory が不要なため、スタンドアロン サーバーが使用されます。このクライアント証明書マッピング認証方法では、パフォーマンスは向上しますが、より多くの構成が必要であり、マッピング作成のためにクライアント証明書にアクセスできる必要があります。
詳細については、Microsoft TechNet Web サイトの「IIS 7.0 で認証を構成する」を参照してください。
IIS 7.0 | IIS 6.0 | |
---|---|---|
注意 | <authentication> の <iisClientCertificateMappingAuthentication> は IIS 7.0 で新たに導入された要素です。 |
<iisClientCertificateMappingAuthentication> 要素は、IIS 6.0 の IIsCertMapper メタベース オブジェクトに代わるものです。 |
<iisClientCertificateMappingAuthentication>
要素は、IIS 7.0 の既定のインストールには含まれていません。インストールするには、次の手順を実行します。
タスク バーで [スタート] ボタンをクリックし、[管理ツール] をポイントして [サーバー マネージャー] をクリックします。
[サーバー マネージャー] ウィンドウのツリー表示で、[役割] を展開して [Web サーバー (IIS)] をクリックします。
[Web サーバー (IIS)] ウィンドウで、[役割サービス] セクションまでスクロールして [役割サービスの追加] をクリックします。
役割サービスの追加ウィザードの [役割サービスの選択] ページで、[IIS クライアント証明書マッピング認証] を選択して、[次へ] をクリックします。
[インストール オプションの確認] ページで [インストール] をクリックします。
[結果] ページで [閉じる] をクリックします。
タスク バーで [スタート] ボタンをクリックし、[コントロール パネル] をクリックします。
コントロール パネルで、[プログラムと機能]、[Windows の機能の有効化または無効化] の順にクリックします。
[Internet Information Services] を展開し、[IIS クライアント証明書マッピング認証] を選択して [OK] をクリックします。
IIS 7.0 では、IIS クライアント証明書マッピング認証を構成するためのユーザー インターフェイスはありません。IIS クライアント証明書マッピング認証をプログラムによって構成する方法の例については、このドキュメントの「サンプル コード」セクションを参照してください。
属性 | 説明 |
---|---|
defaultLogonDomain |
オプションの string 属性。 ユーザーを認証するためにサーバーで使用する既定のドメインを指定します。 |
enabled |
オプションの Boolean 属性。 IIS を使用したクライアント証明書マッピング認証を有効にするかどうかを指定します。 既定値は false です。 |
logonMethod |
オプションの enum 属性。 logonMethod 属性には、次のいずれかの値を指定できます(これらの値の詳細については、「LogonUser (英語)」を参照してください)。 既定値は ClearText です。--------------------------------------------------------------------------------------------------------- 値: Batch 説明:
値: ClearText 説明:
値: Interactive 説明:
値: Network 説明:
|
manyToOneCertificateMappingsEnabled |
オプションの Boolean 属性。 多対 1 マッピングを有効にするかどうかを指定します。 既定値は true です。 |
oneToOneCertificateMappingsEnabled |
オプションの Boolean 属性。 1 対 1 マッピングを有効にするかどうかを指定します。 既定値は true です。 |
要素 | 説明 |
---|---|
manyToOneMappings |
オプションの要素。 証明書を認証してユーザー アカウントを割り当てるクライアント証明書をワイルドカードの条件にマップします。 |
oneToOneMappings |
オプションの要素。 1 対 1 クライアント証明書マッピングを指定します。 |
次の構成サンプルでは、Default Web Site に対して次のアクションを実行します。
- 多対 1 証明書マッピングを使用して、IIS クライアント証明書マッピング認証を有効にします。
- Contoso に一致するクライアント証明書の件名の組織名のフィールドに基づいて、ユーザー アカウントに対する多対 1 証明書マッピング ルールを作成します。
- 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:Encrypted-Password-Data:enc]">
<rules>
<add certificateField="Subject"
certificateSubField="O"
matchCriteria="Contoso"
compareCaseSensitive="true" />
</rules>
</add>
</manyToOneMappings>
</iisClientCertificateMappingAuthentication>
</authentication>
<access sslFlags="Ssl, SslNegotiateCert" />
</security>
</system.webServer>
</location>
次の構成サンプルでは、Default Web Site で 1 対 1 証明書マッピングを使用した IIS クライアント証明書マッピング認証を有効にして、1 つのユーザー アカウントに対して単一の 1 対 1 証明書マッピングを作成し、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:AesProvider:Encrypted-Password-Data:enc]"
certificate="Base64-Encoded-Certificate-Data" />
</oneToOneMappings>
</iisClientCertificateMappingAuthentication>
</authentication>
</security>
</system.webServer>
</location>
注 : このトピックのすべてのサンプルで使用されている Base-64 でエンコードされた証明書データを取得するには、次の手順を使用して証明書をエクスポートします。
- [スタート] ボタンをクリックして、[ファイル名を指定して実行] をクリックします。
- 「MMC」と入力し、[OK] をクリックします。
- Microsoft 管理コンソールが開いたら、[ファイル] をクリックし、[スナップインの追加と削除] をクリックします。
- [スナップインの追加と削除] ダイアログ ボックスが開きます。
- 利用できるスナップインの一覧で [証明書] を強調表示し、[追加] をクリックします。
- [ユーザー アカウント] の証明書を管理するように選択して、[完了] をクリックします。
- [OK] をクリックしてダイアログ ボックスを閉じます。
- Microsoft 管理コンソールで、次の手順を実行します。
- [証明書 - 現在のユーザー] を展開し、[個人]、[証明書] の順にクリックします。
- 証明書の一覧で、エクスポートする証明書を右クリックし、[すべてのタスク] をクリックし、次に [エクスポート] をクリックします。
- 証明書のエクスポート ウィザードが開きます。
- [次へ] をクリックします。
- [いいえ、秘密キーをエクスポートしません] を選択し、[次へ] をクリックします。
- エクスポートの形式に [Base-64 encoded X.509 9 (.CER)] を選択し、[次へ] をクリックします。
- 証明書を "MyCertificate.cer" としてデスクトップに保存するように選択して、[次へ] をクリックします。
- [完了] をクリックします。エクスポートが成功したことを示すダイアログ ボックスが表示されます。
- Microsoft 管理コンソールを閉じます。
- Windows のメモ帳を使用して、エクスポートした MyCertificate.cer ファイルを開きます。
- テキストの先頭から "-----BEGIN CERTIFICATE-----" を削除します。
- テキストの末尾から "-----END CERTIFICATE-----" を削除します。
- すべての行を 1 行に連結します。これが、このトピック内のすべてのサンプルで使用される Base-64 でエンコードされた証明書データです。
次のコード サンプルでは、Default Web Site に対して次のアクションを実行します。
- 多対 1 証明書マッピングを使用して、IIS クライアント証明書マッピング認証を有効にします。
- Contoso に一致するクライアント証明書の件名の組織名のフィールドに基づいて、ユーザー アカウントに対する多対 1 証明書マッピング ルールを作成します。
- SSL を要求し、クライアント証明書をネゴシエートするようサイトを構成します。
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
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();
}
}
}
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
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();
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()
次のコード サンプルでは、Default Web Site で 1 対 1 証明書マッピングを使用した IIS クライアント証明書マッピング認証を有効にして、1 つのユーザー アカウントに対して単一の 1 対 1 証明書マッピングを作成し、SSL を要求しクライアント証明書をネゴシエートするようサイトを構成します。
注 : 次のコード サンプルについて Base-64 でエンコードされた証明書データを取得するには、このドキュメントの「構成」セクションの手順に従って証明書をエクスポートしてください。
注 : 証明書文字列に AppCmd.exe によって解析できない文字が存在するため、IIS 1 対 1 証明書マッピングの構成には AppCmd.exe を使用しないでください。
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();
}
}
}
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
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();
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()