次の方法で共有


FTP SSL クライアント証明書 <sslClientCertificates>

概要

<sslClientCertificates> 要素には、FTP サイトの SSL クライアント証明書オプションを指定します。 より具体的には、この要素には次の属性があります。これらについて、このトピックの構成セクションで詳しく説明します。

  • clientCertificatePolicy 属性には、クライアント証明書を許可するか、必須にするか、無視するかを指定します。
  • validationFlags 属性には、証明書の失効を確認する際の FTP サイトの動作を指定します。
  • revocationFreshnessTime 属性には、失効リストの有効期間を指定します。
  • revocationUrlRetrievalTimeout 属性には、証明書の失効情報を取得する際のタイムアウトを指定します
  • useActiveDirectoryMapping 属性には、クライアント証明書に対して Active Directory マッピングを許可するかどうかを指定します。 注: この属性は、Active Directory を使って証明書マッピングを構成するために、<clientCertAuthentication> 要素と組み合わせて使われます。

互換性

バージョン メモ
IIS 10.0 <sslClientCertificates> 要素は、IIS 10.0 では変更されませんでした。
IIS 8.5 <sslClientCertificates> 要素は、IIS 8.5 では変更されませんでした。
IIS 8.0 <sslClientCertificates> 要素は IIS 8.0 では変更されませんでした。
IIS 7.5 <security> 要素の <sslClientCertificates> 要素は、IIS 7.5 の機能として付属しています。
IIS 7.0 <security> 要素の <sslClientCertificates> 要素が、IIS 7.0 用の別個のダウンロードとして FTP 7.0 で導入されました。
IIS 6.0 <ftpServer> 要素とその子要素は、LM/MSFTPSVC メタベース パスにある IIS 6.0 の FTP 設定を置き換えます。

Note

FTP 7.0 サービスと FTP 7.5 サービスは IIS 7.0 とは別に出荷され、次の URL からモジュールをダウンロードしてインストールする必要がありました。

https://www.iis.net/expand/FTP

Windows 7 と Windows Server 2008 R2 では、FTP 7.5 サービスは IIS 7.5 の機能として付属しているため、FTP サービスのダウンロードは必要なくなりました。

段取り

Web サーバーの FTP 公開をサポートするには、FTP サービスをインストールする必要があります。 そのためには、次のステップに従います。

Windows Server 2012 または Windows Server 2012 R2

  1. タスク バーで [サーバー マネージャー]をクリックします。

  2. [サーバー マネージャー] で、[管理] メニューを選択し、[役割と機能の追加] を選択します。

  3. [役割と機能の追加] ウィザードで、[次へ] をクリックします。 インストールの種類を選択し、[次へ] をクリックします。 対象サーバーを選択し、[次へ] をクリックします。

  4. [サーバーの役割] ページで、[Web サーバー (IIS)] を展開して、[FTP サーバー] を選びます。

    Note

    FTP サービスに対して ASP.NET メンバーシップ認証または IIS マネージャー認証をサポートするには、[FTP Service] に加えて[FTP 拡張] も選択する必要があります。
    F T P 拡張機能が選択された状態で展開された [Web Server I I S] ペインのスクリーンショット。 .

  5. [次へ] をクリックし、[機能の選択] ページで再度 [次へ] をクリックします。

  6. [インストール オプションの確認] ページで、[インストール] をクリックします。

  7. [結果] ページで、 [閉じる]をクリックします。

Windows 8 または Windows 8.1

  1. [スタート] 画面で、ポインターを左下隅まで移動し、[スタート] ボタンを右クリックし、[コントロール パネル] をクリックします。

  2. [コントロール パネル][プログラムと機能] をクリックし、[Windows の機能の有効化または無効化] をクリックします。

  3. [インターネット インフォメーション サービス] を展開し、[FTP サーバー] を展開します。

    Note

    FTP サービスに対して ASP.NET メンバーシップ認証または IIS マネージャー認証をサポートするには、[FTP 拡張] も選択する必要があります。
    [F T P 拡張機能] が選択された状態で展開された [インターネット インフォメーション サービスと F T P サーバー] ウィンドウの画像。

  4. OK をクリックします。

  5. 閉じるをクリックします。

Windows Server 2008 R2

  1. タスク バーで [スタート] をクリックし、[管理ツール] をポイントして、[サーバー マネージャ] をクリックします。

  2. [サーバー マネージャ] 階層ウィンドウで [役割] を展開し、[Web サーバー (IIS)] をクリックします。

  3. [Web サーバー (IIS)] ウィンドウで、[役割サービス] セクションまでスクロールし、[役割サービスの追加] をクリックします。

  4. [役割サービスの追加] ウィザード[役割サービスの選択] ページで [FTP サーバー] を展開します。

  5. [FTP Service] を選択します。

    Note

    FTP サービスに対して ASP.NET メンバーシップ認証または IIS マネージャー認証をサポートするには、[FTP 拡張] も選択する必要があります。
    [役割サービスの追加ウィザード] の [役割サービスの選択] ページのスクリーンショット。[F T P サーバー] ウィンドウが展開され、F T P サービスが選択されています。

  6. 次へ をクリックします。

  7. [インストール オプションの確認] ページで、[インストール] をクリックします。

  8. [結果] ページで、 [閉じる]をクリックします。

Windows 7

  1. タスク バーで、[スタート][コントロール パネル] の順にクリックします。

  2. [コントロール パネル][プログラムと機能] をクリックし、[Windows の機能の有効化または無効化] をクリックします。

  3. [インターネット インフォメーション サービス][FTP サーバー] の順に展開します。

  4. [FTP Service] を選択します。

    Note

    FTP サービスに対して ASP.NET メンバーシップ認証または IIS マネージャー認証をサポートするには、[FTP 拡張] も選択する必要があります。
    [F T P 拡張機能] が選択されていることを示す展開された [インターネット インフォメーション サービスと F T P サーバー] ウィンドウの画像。

  5. OK をクリックします。

Windows Server 2008 または Windows Vista

  1. 次の URL からインストール パッケージをダウンロードします。

  2. 次のチュートリアルの手順に従って、FTP サービスをインストールします。

操作方法

現時点では、FTP サイトのクライアント証明書認証設定を構成できるユーザー インターフェイスはありません。 FTP サイトに対してクライアント証明書認証設定のカスタム機能を構成する方法の詳細については、このドキュメントの「構成」と「サンプル コード」のセクションを参照してください。

構成

<sslClientCertificates> 要素は、サイト レベルで構成されます。

属性

属性 説明
clientCertificatePolicy 省略可能な列挙型属性。

クライアント証明書ポリシーを指定します。
Value 説明
CertIgnore SSL セッションに対してクライアント証明書がネゴシエートされないことを指定します。

数値は 0 です。
CertAllow クライアント証明書を許可することを指定します。 クライアントで証明書を送信することを選んだ場合、証明書が有効である必要があります。また、サーバーがそれを正常に検証できる必要があります。

数値は 1 です。
CertRequire クライアント証明書が必須であることを指定します。 有効なクライアント証明書をサーバーに送信しない限り、FTP クライアントは接続を許可されません。

数値は 2 です。
既定値は CertIgnore です。
validationFlags 省略可能な flags 属性。

クライアント証明書の検証に影響するフラグを指定します。
Value 説明
NoRevocationCheck

証明書の失効チェックをスキップすることを指定します。

警告: 失効の検証をスキップすることは推奨されません。

数値は 1 です。

CertChainRevocationCheckCacheOnly 失効チェックのアクセス対象をキャッシュされた URL のみに指定します。

数値は 2 です。
CertChainCacheOnlyUrlRetrieval 証明書チェーンの構築時にキャッシュされた URL のみを指定します。 インターネットとイントラネットでは、URL ベースのオブジェクトは検索されません。

数値は 4 です。
CertNoUsageCheck クライアント証明書の使用フラグを確認しません。 使用状況チェックは既定で有効になっており、確実に "クライアント認証" を許可するクライアント証明書のみを許可することを目的としています。

数値は 8 です。
既定値はありません。
revocationFreshnessTime 省略可能な timeSpan 属性。

失効リストが有効な時間を指定します。

既定値は 00:00:00 です。
revocationUrlRetrievalTimeout 省略可能な timeSpan 属性。

証明書の失効情報を取得する際のタイムアウトを指定します。

既定値は 00:01:00 です。
useActiveDirectoryMapping 省略可能で、 Boolean 型の属性。

クライアント証明書に対して Active Directory マッピングを許可する必要がある場合は、true、それ以外の場合は、false。 Active Directory マッピングにより、ドメイン ユーザーは Active Directory で構成されたクライアント証明書を使ってログオンできます。

注: この機能で許可されることは、SSL レイヤーがクライアント証明書をユーザー トークンにマップすることのみです。トークンが自動的には使われることはありません。 <clientCertAuthentication> 要素は、"USER" と "PASS" の各コマンドで指定された資格情報ではなく、マップされたトークンを FTP で使用できるようにするために使われます。

既定値は false です。

子要素

なし。

構成サンプル

次のサンプルは、データ チャネルとコントロール チャネルの両方に SSL とクライアント証明書を必須とする FTP サイトを示しています。

<site name="ftp.example.com" id="5">
   <application path="/">
      <virtualDirectory path="/" physicalPath="c:\inetpub\www.example.com" />
   </application>
   <bindings>
      <binding protocol="ftp" bindingInformation="*:21:" />
   </bindings>
   <ftpServer serverAutoStart="true">
      <security>
         <authentication>
            <anonymousAuthentication enabled="false" />
            <basicAuthentication enabled="true" />
         </authentication>
         <ssl serverCertHash="57686f6120447564652c2049495320526f636b73"
            controlChannelPolicy="SslRequire"
            dataChannelPolicy="SslRequire" />
         <sslClientCertificates clientCertificatePolicy="CertRequire"
            useActiveDirectoryMapping="false" />
      </security>
   </ftpServer>
</site>

サンプル コード

次の例では、データ チャネルとコントロール チャネルの両方に対してクライアント証明書を必須にし、SSL を必須にするように FTP サイトを構成しています。

AppCmd.exe

appcmd.exe set config -section:system.applicationHost/sites /[name='ftp.example.com'].ftpServer.security.ssl.serverCertHash:"57686f6120447564652c2049495320526f636b73" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /[name='ftp.example.com'].ftpServer.security.ssl.controlChannelPolicy:"SslRequire" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /[name='ftp.example.com'].ftpServer.security.ssl.dataChannelPolicy:"SslRequire" /commit:apphost

appcmd.exe set config -section:system.applicationHost/sites /[name='ftp.example.com'].ftpServer.security.sslClientCertificates.clientCertificatePolicy:"CertRequire" /commit:apphost
appcmd.exe set config -section:system.applicationHost/sites /[name='ftp.example.com'].ftpServer.security.sslClientCertificates.useActiveDirectoryMapping:"False" /commit:apphost

Note

AppCmd.exe を使用してこれらの設定を構成するときは、commit パラメーターを必ず 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 sitesSection = config.GetSection("system.applicationHost/sites");
         ConfigurationElementCollection sitesCollection = sitesSection.GetCollection();

         ConfigurationElement siteElement = FindElement(sitesCollection, "site", "name", @"ftp.example.com");
         if (siteElement == null) throw new InvalidOperationException("Element not found!");

         ConfigurationElement ftpServerElement = siteElement.GetChildElement("ftpServer");
         ConfigurationElement securityElement = ftpServerElement.GetChildElement("security");

         ConfigurationElement sslElement = securityElement.GetChildElement("ssl");
         sslElement["serverCertHash"] = @"57686f6120447564652c2049495320526f636b73";
         sslElement["controlChannelPolicy"] = @"SslRequire";
         sslElement["dataChannelPolicy"] = @"SslRequire";

         ConfigurationElement sslClientCertificatesElement = securityElement.GetChildElement("sslClientCertificates");
         sslClientCertificatesElement["clientCertificatePolicy"] = @"CertRequire";
         sslClientCertificatesElement["useActiveDirectoryMapping"] = false;

         serverManager.CommitChanges();
      }
   }
   
   private static ConfigurationElement FindElement(ConfigurationElementCollection collection, string elementTagName, params string[] keyValues)
   {
      foreach (ConfigurationElement element in collection)
      {
         if (String.Equals(element.ElementTagName, elementTagName, StringComparison.OrdinalIgnoreCase))
         {
            bool matches = true;
            for (int i = 0; i < keyValues.Length; i += 2)
            {
               object o = element.GetAttributeValue(keyValues[i]);
               string value = null;
               if (o != null)
               {
                  value = o.ToString();
               }
               if (!String.Equals(value, keyValues[i + 1], StringComparison.OrdinalIgnoreCase))
               {
                  matches = false;
                  break;
               }
            }
            if (matches)
            {
               return element;
            }
         }
      }
      return null;
   }
}

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 sitesSection As ConfigurationSection = config.GetSection("system.applicationHost/sites")
      Dim sitesCollection As ConfigurationElementCollection = sitesSection.GetCollection

      Dim siteElement As ConfigurationElement = FindElement(sitesCollection, "site", "name", "ftp.example.com")
      If (siteElement Is Nothing) Then
         Throw New InvalidOperationException("Element not found!")
      End If

      Dim ftpServerElement As ConfigurationElement = siteElement.GetChildElement("ftpServer")
      Dim securityElement As ConfigurationElement = ftpServerElement.GetChildElement("security")

      Dim sslElement As ConfigurationElement = securityElement.GetChildElement("ssl")
      sslElement("serverCertHash") = "57686f6120447564652c2049495320526f636b73"
      sslElement("controlChannelPolicy") = "SslRequire"
      sslElement("dataChannelPolicy") = "SslRequire"

      Dim sslClientCertificatesElement As ConfigurationElement = securityElement.GetChildElement("sslClientCertificates")
      sslClientCertificatesElement("clientCertificatePolicy") = "CertRequire"
      sslClientCertificatesElement("useActiveDirectoryMapping") = False

      serverManager.CommitChanges()
   End Sub

   Private Function FindElement(ByVal collection As ConfigurationElementCollection, ByVal elementTagName As String, ByVal ParamArray keyValues() As String) As ConfigurationElement
      For Each element As ConfigurationElement In collection
         If String.Equals(element.ElementTagName, elementTagName, StringComparison.OrdinalIgnoreCase) Then
            Dim matches As Boolean = True
            Dim i As Integer
            For i = 0 To keyValues.Length - 1 Step 2
               Dim o As Object = element.GetAttributeValue(keyValues(i))
               Dim value As String = Nothing
               If (Not (o) Is Nothing) Then
                  value = o.ToString
               End If
               If Not String.Equals(value, keyValues((i + 1)), StringComparison.OrdinalIgnoreCase) Then
                  matches = False
                  Exit For
               End If
            Next
            If matches Then
               Return element
            End If
         End If
      Next
      Return Nothing
   End Function


End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";

var sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST");
var sitesCollection = sitesSection.Collection;
var siteElementPos = FindElement(sitesCollection, "site", ["name", "ftp.example.com"]);

if (siteElementPos == -1) throw "Element not found!";

var siteElement = sitesCollection.Item(siteElementPos);
var ftpServerElement = siteElement.ChildElements.Item("ftpServer");
var securityElement = ftpServerElement.ChildElements.Item("security");

var sslElement = securityElement.ChildElements.Item("ssl");
sslElement.Properties.Item("serverCertHash").Value = "57686f6120447564652c2049495320526f636b73";
sslElement.Properties.Item("controlChannelPolicy").Value = "SslRequire";
sslElement.Properties.Item("dataChannelPolicy").Value = "SslRequire";

var sslClientCertificatesElement = securityElement.ChildElements.Item("sslClientCertificates");
sslClientCertificatesElement.Properties.Item("clientCertificatePolicy").Value = "CertRequire";
sslClientCertificatesElement.Properties.Item("useActiveDirectoryMapping").Value = false;

adminManager.CommitChanges();

function FindElement(collection, elementTagName, valuesToMatch) {
   for (var i = 0; i < collection.Count; i++) {
      var element = collection.Item(i);
      if (element.Name == elementTagName) {
         var matches = true;
         for (var iVal = 0; iVal < valuesToMatch.length; iVal += 2) {
            var property = element.GetPropertyByName(valuesToMatch[iVal]);
            var value = property.Value;
            if (value != null) {
               value = value.toString();
            }
            if (value != valuesToMatch[iVal + 1]) {
               matches = false;
               break;
            }
         }
         if (matches) {
            return i;
         }
      }
   }
   return -1;
}

VBScript

Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"

Set sitesSection = adminManager.GetAdminSection("system.applicationHost/sites", "MACHINE/WEBROOT/APPHOST")
Set sitesCollection = sitesSection.Collection
siteElementPos = FindElement(sitesCollection, "site", Array("name", "ftp.example.com"))

If siteElementPos = -1 Then
Wscript.Echo "Element not found!"
WScript.Quit
End If

Set siteElement = sitesCollection.Item(siteElementPos)
Set ftpServerElement = siteElement.ChildElements.Item("ftpServer")
Set securityElement = ftpServerElement.ChildElements.Item("security")

Set sslElement = securityElement.ChildElements.Item("ssl")
sslElement.Properties.Item("serverCertHash").Value = "57686f6120447564652c2049495320526f636b73"
sslElement.Properties.Item("controlChannelPolicy").Value = "SslRequire"
sslElement.Properties.Item("dataChannelPolicy").Value = "SslRequire"

Set sslClientCertificatesElement = securityElement.ChildElements.Item("sslClientCertificates")
sslClientCertificatesElement.Properties.Item("clientCertificatePolicy").Value = "CertRequire"
sslClientCertificatesElement.Properties.Item("useActiveDirectoryMapping").Value = False

adminManager.CommitChanges()

Function FindElement(collection, elementTagName, valuesToMatch)
   For i = 0 To CInt(collection.Count) - 1
      Set element = collection.Item(i)
      If element.Name = elementTagName Then
         matches = True
         For iVal = 0 To UBound(valuesToMatch) Step 2
            Set property = element.GetPropertyByName(valuesToMatch(iVal))
            value = property.Value
            If Not IsNull(value) Then
               value = CStr(value)
            End If
            If Not value = CStr(valuesToMatch(iVal + 1)) Then
               matches = False
               Exit For
            End If
         Next
         If matches Then
            Exit For
         End If
      End If
   Next
   If matches Then
      FindElement = i
   Else
      FindElement = -1
   End If
End Function