TsgcWebSocketClient › 属性 › TLSOptions
配置 TLS 启用时使用的证书、TLS 版本、ALPN、IOHandler 及其他安全连接详情。
property TLSOptions: TsgcWSTLS_Options read FTLSOptions write SetTLSOptions;
Preset=tlspCustom
仅当 TLS 为 True 时可访问。子属性包括 RootCertFile、CertFile、KeyFile、Password、VerifyCertificate、VerifyDepth、Version(从 tlsUndefined 到 tls1_3)、ALPNProtocols 和 IOHandler(iohOpenSSL、iohSChannel、iohAndroidTLS 或 iohAppleTLS)。在 Android 上,iohAndroidTLS 使用平台原生 TLS(javax.net.ssl.SSLEngine),在 iOS 和 macOS 上,iohAppleTLS 使用 Apple 原生 TLS,因此无需部署 OpenSSL 库;原生平台 TLS 需要 Enterprise 版本。OpenSSL 特定的设置位于 OpenSSL_Options 下,SChannel 特定的设置位于 SChannel_Options 下。
Preset 通过一次赋值应用一组安全默认值。使用 tlspCustom(默认值)时,每个选项都保持您手动配置的值,从而保留以前的行为。设置 Preset := tlspSecureDefaults 会启用证书验证(VerifyCertificate := True),将 Version 提升到至少 TLS 1.2(当配置了较低或未定义的版本时),并启用对服务器证书的主机名检查(OpenSSL X509Checks 主机名验证)。应用预设后,仍可以单独调整各个选项。
oClient := TsgcWebSocketClient.Create(nil);
oClient.URL := 'wss://www.esegece.com:2053';
oClient.TLSOptions.Version := tls1_2;
oClient.TLSOptions.VerifyCertificate := true;
oClient.TLSOptions.RootCertFile := 'cacert.pem';
oClient.Active := true;