TsgcWebSocketClient | SChannel Verbindingsinformatie ophalen

Zodra de client verbinding heeft gemaakt met de beveiligde server, kunt u informatie opvragen over welke TLS-versie wordt gebruikt (TLS 1.2, TLS 1.3, enz.), de gebruikte cipher, sterkte en meer.

 

Roep de functie GetInfo of the SChannel Handler to access this info. U kunt access the SSL Handler using de methode OnSSLAfterCreateHandler, which is called after the SChannel Handler is created. After de client connects to de server, if the SSL Handler is assigned, call the functie GetInfo and if succesvol, will return the verbinding data.

 


oClient = new TsgcWebSocketClient();
oClient->URL = "wss://www.esegece.com:2053";
oClient->TLSOptions->Version = tls1_2;
oClient->TLSOptions->IOHandler = iohSChannel;
oClient->OnSSLAfterCreateHandler = OnSSLAfterCreateHandlerEvent;
oClient->OnConnect = OnConnectEvent;
oClient->Active = true;
void OnSSLAfterCreateHandlerEvent(TObject *Sender, TwsSSLHandler aType, 
  TIdSSLIOHandlerSocketBase *aSSLHandler)
{
  if (aSSLHandler->ClassType() == __classid(TsgcIdSSLIOHandlerSocketSChannel))
  {
    SSL = dynamic_cast<TsgcIdSSLIOHandlerSocketSChannel*>(aSSLHandler);
  }
}
void OnConnectEvent(TsgcWSConnection *Connection)
{
  if (SSL != NULL)
  {
    TsgcSChannelConnectionInfo oInfo = SSL->GetInfo();
    if (oInfo->Protocol != tls1_2)
    {
      throw Exception("Client cannot connect using TLS 1.2");
    }
  }
}