Starting from 4.0 sgcWebSockets version, there is a new client component TsgcWebSocketClient_WinHTTP based on WinHTTP API which is not based on indy like TsgcWebSocketClient. All of them, can connect to WebSocket server, but here are some differences between these components, let's see the main features of each one.

  • Yes, requires OpenSSL
  • No, only Blocking mode
  • Yes, Requires Win8.+


When a connection is secure, sometimes it's interesting to get certificate info to show user company name for example. To do this, just use OnSSLGetHandler, where you can access to some SSL properties and handle OnVeryPeerEvent, where there is a parameter called Certificate, where you can get certificate info.


procedure OnSSLGetHandler(Sender: TObject; aType:
    TwsSSLHandler; var aSSLHandler: TIdSSLIOHandlerSocketBase);
  aSSLHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
  TIdSSLIOHandlerSocketOpenSSL(aSSLHandler).SSLOptions.VerifyMode := [sslvrfPeer];
  TIdSSLIOHandlerSocketOpenSSL(aSSLHandler).SSLOptions.Method := sslvTLSv1;
  TIdSSLIOHandlerSocketOpenSSL(aSSLHandler).SSLOptions.Mode := sslmClient;

  TIdSSLIOHandlerSocketOpenSSL(aSSLHandler).OnVerifyPeer := OnVerifyPeerEvent;

function OnVerifyPeerEvent(Certificate: TIdX509; AOk: Boolean;
    ADepth: Integer): boolean;
  Result := True;

// ... read certificate properties
//  Certificate