StreamWebSocket.ServerCustomValidationRequested イベント

定義

セキュリティで保護されたサーバー URI (wss: プロトコル) への新しい StreamWebSocket 接続が検証されるときに発生します。 接続のカスタム サーバー検証を実装する場合は、このイベントを処理します。

// Register
event_token ServerCustomValidationRequested(TypedEventHandler<StreamWebSocket, WebSocketServerCustomValidationRequestedEventArgs const&> const& handler) const;

// Revoke with event_token
void ServerCustomValidationRequested(event_token const* cookie) const;

// Revoke with event_revoker
StreamWebSocket::ServerCustomValidationRequested_revoker ServerCustomValidationRequested(auto_revoke_t, TypedEventHandler<StreamWebSocket, WebSocketServerCustomValidationRequestedEventArgs const&> const& handler) const;
public event TypedEventHandler<StreamWebSocket,WebSocketServerCustomValidationRequestedEventArgs> ServerCustomValidationRequested;
function onServerCustomValidationRequested(eventArgs) { /* Your code */ }
streamWebSocket.addEventListener("servercustomvalidationrequested", onServerCustomValidationRequested);
streamWebSocket.removeEventListener("servercustomvalidationrequested", onServerCustomValidationRequested);
- or -
streamWebSocket.onservercustomvalidationrequested = onServerCustomValidationRequested;
Public Custom Event ServerCustomValidationRequested As TypedEventHandler(Of StreamWebSocket, WebSocketServerCustomValidationRequestedEventArgs) 

イベントの種類

Windows の要件

デバイス ファミリ
Windows 10 Anniversary Edition (10.0.14393.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v3.0 で導入)

注釈

このイベントは、既定の OS 検証が正常に実行された後に発生し、既定の OS 検証に IgnorableServerCertificateErrors コントロール オプションを考慮することが含まれていることに注意してください。

WebSocketServerCustomValidationRequestedEventArgs プロパティを使用して、検証のために提供されているサーバー証明書と中間証明書にアクセスします。

適切な完了を確保するために、カスタム検証プロセスに非同期操作が含まれる場合は、 WebSocketServerCustomValidationRequestedEventArgs.GetDeferral メソッドを使用して、検証操作の期間中にイベント ハンドラーが保持する遅延オブジェクトを取得してください。 検証が完了したら、検証を受け入れるか拒否するかに関係なく 、Deferral.Complete を呼び出す必要があります。

このイベント ハンドラーで実行できる検証の種類の例として、サーバー証明書を、予想されるサーバー証明書と一致するローカルに格納された信頼された証明書と比較できます。 イベント ハンドラーでは、ローカル証明書の SHA-256 ハッシュとサーバー証明書のハッシュを比較します。 ハッシュ値が一致する場合、証明書は一致すると見なされ、サーバーの検証は成功する必要があります。 ハッシュ値が一致しない場合、証明書は一致せず、検証は失敗します。

検証エラーを示すには、 WebSocketServerCustomValidationRequestedEventArgs.Reject メソッドを呼び出します。 検証が成功したことを示すには、イベント ハンドラーからを返します。

検証が成功するか失敗したかに関係なく、検証プロセスの開始時に取得した遅延オブジェクトで Deferral.Complete を呼び出す必要があります。

適用対象