Share via


HttpBaseProtocolFilter.ServerCustomValidationRequested Event

Definition

This event is raised when the SSL/TLS connection is being established with the server. You should implement an event handler for this event if you need to perform extra validation (in addition to the OS default) of the server SSL certificate.

// Register
event_token ServerCustomValidationRequested(TypedEventHandler<HttpBaseProtocolFilter, HttpServerCustomValidationRequestedEventArgs const&> const& handler) const;

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

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

Event Type

Windows requirements

Device family
Windows 10 Anniversary Edition (introduced in 10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v3.0)

Remarks

Default OS validation of the server certificate is performed before raising this event. If the certificate fails this validation, the connection is terminated and your event handler is not called.

In order to skip parts of the OS validation (not recommended for production scenarios), use the IgnorableServerCertificateErrors property to specify the errors that you want to ignore. Then as long as the certificate does not have any other errors, the OS validation will be considered successful and your event handler will be called.

The event handler code is executed as part of a synchronous callback in the OS during the SSL/TLS connection establishment. Avoid performing long-running tasks within the event handler code to prevent the server from timing out during the connection.

If you need to call async APIs within your event handler code, you must take a deferral (See HttpServerCustomValidationArgs.GetDeferral) before calling the asynchronous APIs. Once you are done, call the deferral.Complete method to return control from your handler code.

The following snippet shows how to subscribe to this event.

HttpBaseProtocolFilter.ServerCustomValidationRequest += (sender, args) =>
{
	var cert = args.ServerCertificate
	// Your custom cert validation code here.
}

Applies to