クライアントがセキュアサーバーに接続すると、使用されている TLS バージョン(TLS 1.2、TLS 1.3 など)、使用されている暗号、強度などに関する情報をリクエストできます。
この情報にアクセスするには、SChannel HandlerのGetInfo関数を呼び出します。SSL Handlerには、SChannel Handlerの作成後に呼び出されるOnSSLAfterCreateHandlerメソッドを使用してアクセスできます。クライアントがサーバーに接続した後、SSL Handlerが割り当てられている場合は、GetInfo関数を呼び出します。成功すると、接続データを返します。
usessgcIdSSL, sgcSSL_SChannel_Indy, sgcSSL_SChannel;var SSL: TsgcIdSSLIOHandlerSocketSChannel; oClient := TsgcWebSocketClient.Create(nil); 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; procedure OnSSLAfterCreateHandlerEvent(Sender: TObject; aType: TwsSSLHandler; aSSLHandler: TIdSSLIOHandlerSocketBase); begin if aSSLHandler.ClassType = TsgcIdSSLIOHandlerSocketSChannel then SSL := TsgcIdSSLIOHandlerSocketSChannel(aSSLHandler); end; procedure OnConnectEvent(Connection: TsgcWSConnection); var oInfo: TsgcSChannelConnectionInfo; begin if Assigned(SSL) then begin oInfo := SSL.GetInfo; if (oInfo.Protocol != tls1_2) then raise Exception.Create('Client cannot connect using TLS 1.2'); end; end;