TsgcHTTP2Client › 属性 › TLSOptions
配置 HTTP/2 over TLS 所使用的证书、TLS 版本、ALPN、IOHandler 及其他安全连接细节。
property TLSOptions: TsgcTCPTLS_Options read FTLSOptions write SetTLSOptions;
—
当 TLS 为 True 时使用。子属性包括 RootCertFile、CertFile、KeyFile、Password、VerifyCertificate、VerifyDepth、Version(从 tlsUndefined 到 tls1_3)、ALPNProtocols 和 IOHandler(iohOpenSSL 或 iohSChannel)。HTTP/2 需要 ALPN 在 TLS 握手期间通告 h2 协议;组件会自动将 h2 填充到 ALPN 列表,但如果服务器需要其他标识符,可扩展 ALPNProtocols。OpenSSL 特定设置在 OpenSSL_Options 下,SChannel 特定设置在 SChannel_Options 下。HTTP/2 建议使用 TLS 1.2 或更高版本。
oHTTP2 := TsgcHTTP2Client.Create(nil);
oHTTP2.Host := 'http2.akamai.com';
oHTTP2.Port := 443;
oHTTP2.TLS := True;
oHTTP2.TLSOptions.Version := tls1_2;
oHTTP2.TLSOptions.VerifyCertificate := True;
oHTTP2.TLSOptions.RootCertFile := 'cacert.pem';