次の方法で共有


セキュリティ チャネル レイヤーの例

次の例は、チャネル層のセキュリティを示しています

TCP 経由の Windows トランスポート セキュリティ: クライアント: RequestReplyTcpClientWithWindowsTransportSecurityExample、Server: RequestReplyTcpServerWithWindowsTransportSecurityExample

名前付きパイプを介した Windows トランスポート セキュリティ: Client: RequestReplyNamedPipesClientWithWindowsTransportSecurityExample、Server: RequestReplyNamedPipesServerWithWindowsTransportSecurityExample

SSL トランスポート セキュリティ: クライアント: HttpClientWithSslExample、Server: HttpServerWithSslExample

SSL 混合モードセキュリティ経由のユーザー名: クライアント: HttpClientWithUsernameOverSslExample、Server: HttpServerWithUsernameOverSslExample

SSL 混合モード セキュリティを介したユーザー名: クライアント: HttpClientWithKerberosOverSslExample、Server: HttpServerWithKerberosOverSslExample

SSL 混合モード セキュリティ経由のユーザー名: MetadataImportWithUsernameOverSslExample。 SSL 混合モード セキュリティ経由で発行されたトークン: MetadataImportWithIssuedTokenOverSslExample。 SSL 混合モード セキュリティ経由の X509 証明書: MetadataImportWithX509OverSslExample

セキュリティ サンプルのOne-Timeセットアップ

WWSAPI セキュリティの例を実行するには、SSL 用のクライアント証明書とサーバー証明書、および HTTP ヘッダー認証用のローカル ユーザー アカウントを設定する必要があります。 開始する前に、次のツールが必要です。

  • MakeCert.exe (Windows 7 SDK で使用可能)。
  • CertUtil.exeまたはCertMgr.exe (CertUtil.exeは、Windows Server 2003 以降の Windows SDK で使用できます。CertMgr.exeは Windows 7 SDK で使用できます。必要なのは、これらのツールのいずれか 1 つだけです)。
  • HttpCfg.exe: (Windows 2003 または Windows XP を使用している場合にのみ必要です。このツールは Windows XP SP2 サポート ツールで使用でき、Windows Server 2003 Resource Kit Tools CD にも付属しています)。

Windows 7 SDK をインストールして WWSAPI の例を入手した場合は、%ProgramFiles%\Microsoft SDK\Windows\v7.0\bin の下にMakeCert.exeとCertMgr.exeがあります。

コマンド プロンプトから次の 5 ステップのセットアップを実行します (Windows Vista 以降を使用している場合は管理者特権)。

  1. 証明機関 (CA) または発行者となる自己署名証明書を生成する: MakeCert.exe -ss Root -sr LocalMachine -n "CN=Fake-Test-CA" -cy authority -r -sk "CAKeyContainer"
  2. 前の証明書を発行者として使用してサーバー証明書を生成します: MakeCert.exe -ss My -sr LocalMachine -n "CN=localhost" -sky exchange -is Root -ir LocalMachine -in Fake-Test-CA -sk "ServerKeyContainer"
  3. 次のいずれかのコマンドを実行して、サーバー証明書の拇印 (40 文字の SHA-1 ハッシュ) を見つけ、発行者 Fake-Test-CA を持つ localhost という名前の証明書を検索します。
    • CertUtil.exe -store My localhost
    • CertMgr.exe -s -r LocalMachine My
  4. サーバー証明書の拇印を、HTTP.SYSにスペースなしで登録します。
    • Windows Vista 以降 ("appid" オプションは任意の GUID): Netsh.exe http add sslcert ipport=0.0.0.0:8443 appid={00112233-4455-6677-8899-AABBCCDDEEFF} certhash=<40CharacterThumbprintprint>
    • Windows XP または 2003 の場合: ssl -i 0.0.0.0:8443 -h <40CharacterThumbprint> を設定HttpCfg.exe
  5. ローカル ユーザーの作成: Net ユーザー "TestUserForBasicAuth" "TstPWD@*4Bsic" /add

証明書、SSL 証明書バインド、および前の手順で作成したユーザー アカウントをクリーンするには、次のコマンドを実行します。 同じ名前の証明書が複数ある場合は、削除する前にCertMgr.exe入力が必要になります。

  • CertMgr.exe -del -c -n Fake-Test-CA -s -r LocalMachine Root
  • CertMgr.exe -del -c -n localhost -s -r LocalMachine My
  • Netsh.exe http delete sslcert ipport=0.0.0.0:8443 (または ssl -i 0.0.0.0:8443 を削除HttpCfg.exe)
  • Net ユーザー "TestUserForBasicAuth" /delete

Fake-Test-CA という名前のルート証明書が 1 つだけであることを確認します。 わからない場合は、5 段階のセットアップを開始する前に、上記のクリーンアップ コマンドを使用してこれらの証明書をクリーンして (エラーを無視する)、常に安全です。