セキュリティ チャネルレイヤーの例
次の例は、チャネル レイヤー のセキュリティを示しています
TCP 経由の Windows トランスポート セキュリティ: クライアント: RequestReplyTcpClientWithWindowsTransportSecurityExample, Server: RequestReplyTcpServerWithWindowsTransportSecurityExample.
名前付きパイプ経由の Windows トランスポート セキュリティ: クライアント: RequestReplyNamedPipesClientWithWindowsTransportSecurityExample、サーバー: RequestReplyNamedPipesServerWithWindowsTransportSecurityExample。
SSL トランスポート セキュリティ: クライアント: HttpClientWithSslExample, Server: HttpServerWithSslExample.
SSL 混合モード セキュリティ経由のユーザー名: クライアント: HttpClientWithUsernameOverSslExample、サーバー: HttpServerWithUsernameOverSslExample。
SSL 混合モード セキュリティ上のユーザー名: クライアント: HttpClientWithKerberosOverSslExample、サーバー: HttpServerWithKerberosOverSslExample。
SSL 混合モードセキュリティ経由のユーザー名: MetadataImportWithUsernameOverSslExample。 SSL 混合モード セキュリティ経由で発行されるトークン: MetadataImportWithIssuedTokenOverSslExample。 SSL 混合モード セキュリティ経由の X509 証明書: MetadataImportWithX509OverSslExample。
セキュリティ サンプルのワンタイム セットアップ
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 以降を使用している場合は管理者特権)。
- 証明機関 (CA) または発行者になる自己署名証明書を生成: MakeCert.exe -ss Root -sr LocalMachine -n "CN=Fake-Test-CA" -cy authority -r -sk "CAKeyContainer"
- 前の証明書を発行者として使用してサーバー証明書を生成: MakeCert.exe -ss My -sr LocalMachine -n "CN=localhost" -sky exchange -is Root -ir LocalMachine -in Fake-Test-CA -sk "ServerKeyContainer"
- 次のいずれかのコマンドを実行して、サーバー証明書の拇印 (40 文字の SHA-1 ハッシュ) を見つけ、発行者 Fake-Test-CA で localhost という名前の証明書を検索します。
- CertUtil.exe -store My localhost
- CertMgr.exe -s -r LocalMachine My
- サーバー証明書の拇印を、HTTP.SYSにスペースなしで登録します。
- Windows Vista 以降 ("appid" オプションは任意の GUID): Netsh.exe http add sslcert ipport=0.0.0.0:8443 appid={00001111-aaaa-2222-bbbb-3333cccc4444} certhash=<40CharacterThumbprint>
- Windows XP または 2003 の場合: HttpCfg.exe set ssl -i 0.0.0.0:8443 -h <40CharacterThumbprint>
- ローカルユーザの作成: 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 (または HttpCfg.exe delete ssl -i 0.0.0.0:8443)
- Net user "TestUserForBasicAuth" /delete
Fake-Test-CA という名前のルート証明書が 1 つだけであることを確認します。 わからない場合は、5 段階のセットアップを開始する前に、上記のクリーンアップ コマンドを使用してこれらの証明書をクリーンアップ (およびエラーを無視) しても安全です。