SecureConversationServiceCredential.SecurityStateEncoder プロパティ

定義

Cookie のシリアル化をエンコードおよびデコードするためのカスタマイズされた SecurityStateEncoder を取得または設定します。

public:
 property System::ServiceModel::Security::SecurityStateEncoder ^ SecurityStateEncoder { System::ServiceModel::Security::SecurityStateEncoder ^ get(); void set(System::ServiceModel::Security::SecurityStateEncoder ^ value); };
public System.ServiceModel.Security.SecurityStateEncoder SecurityStateEncoder { get; set; }
member this.SecurityStateEncoder : System.ServiceModel.Security.SecurityStateEncoder with get, set
Public Property SecurityStateEncoder As SecurityStateEncoder

プロパティ値

SecurityStateEncoder オブジェクト。これは、DataProtectionSecurityStateEncoderのカスタマイズです。

次のコードは、このプロパティを設定する方法を示しています。

static void Configure(ServiceHost serviceHost)
{
    /*
     * There are certain settings that cannot be configured via app.config.
     * The security state encoder is one of them.
     * Plug in a SecurityStateEncoder that uses the configured certificate
     * to protect the security context token state.
     *
     * Note: You don't need a security state encoder for cookie mode.  This was added to the
     * sample to illustrate how you would plug in a custom security state encoder should
     * your scenario require one.
     * */
    serviceHost.Credentials.SecureConversationAuthentication.SecurityStateEncoder =
            new CertificateSecurityStateEncoder(serviceHost.Credentials.ServiceCertificate.Certificate);

注釈

"Cookie モード" では、サービスは、セキュリティ状態を維持する必要がないように、クライアントに Cookie の形式でセキュリティ コンテキスト トークン (SCT) を発行します。 クライアントは、要求メッセージの保護を解除して検証する方法をサービスが認識できるように、要求メッセージで Cookie を送信します。 SCT はセキュリティで保護されていないネットワーク経由で送信されることが多いため、保護する必要があります。

既定では、Windows Communication Foundation (WCF) は DataProtectionSecurityStateEncoder クラスを使用して、Data Protection API (DPAPI) を使用して Cookie を保護します。 DPAPI を Web ファーム環境で動作させるには、すべてのバックエンド サービスを同じドメイン ユーザー アカウントとして実行する必要があります。 つまり、サービスが Web でホストされている場合、インターネット インフォメーション サービス (IIS) ワーカー プロセスをドメイン ユーザーとして実行するように構成する必要があります。

このプロパティを使用すると、カスタマイズされた SecurityStateEncoder を使用して、DPAPI に依存せず、Cookie の暗号化と暗号化解除を行えます。

適用対象