TsgcWebSocketClientEvents › OnSChannelVerifyPeer

OnSChannelVerifyPeer Event

Fires when SChannel is the TLS IOHandler so the application can verify the server certificate.

Syntax

property OnSChannelVerifyPeer: TsgcSChannelOnVerifyPeerEvent;
// TsgcSChannelOnVerifyPeerEvent = procedure(Sender: TObject; const aContext: TsgcSChannelContext; aError: TsgcSChannelVerifyError; var Accept: Boolean) of object

Default Value

Remarks

When TLSOptions.IOHandler is iohSChannel this event is raised during the TLS handshake so the application can inspect the server certificate and decide whether to accept the connection. The aContext parameter exposes the certificate chain and SChannel context data; aError reports the validation result returned by SChannel (for example, expired, untrusted root, name mismatch). Set Accept to True to continue the handshake or False to abort the connection. When OpenSSL is used instead of SChannel, use OnSSLVerifyPeer.

Example


procedure OnSChannelVerifyPeer(Sender: TObject; const aContext: TsgcSChannelContext;
  aError: TsgcSChannelVerifyError; var Accept: Boolean);
begin
  // accept the certificate only if SChannel reports no validation error
  Accept := aError = schvOK;
end;

Back to Events