TsgcWebSocketServer_HTTPAPI › Properties › SSL
在 http.sys 监听器上启用 TLS/SSL,使客户端能够使用 wss:// 或 https:// 进行连接。
property SSL: Boolean read GetSSL write SetSSL default False;
False
将 SSL 设为 True 以接受安全连接。与基于 OpenSSL 的服务器不同,http.sys 监听器从 Windows 证书存储读取证书:使用目标证书的十六进制指纹配置 SSLOptions.Hash(可选设置 CertStoreName,默认为 MY)。激活时,服务器调用 HttpSetServiceConfiguration 将证书绑定到主机/端口对,这需要管理员权限,除非已用 netsh http add sslcert 预注册绑定,且 BindingOptions.ConfigureSSLCertificate 设为 False。
oServer := TsgcWebSocketServer_HTTPAPI.Create(nil);
oServer.Host := '127.0.0.1';
oServer.Port := 443;
oServer.SSL := true;
oServer.SSLOptions.Hash := 'CERTIFICATE_HASH';
oServer.Active := true;