TsgcWebSocketHTTPServer › 属性 › SSL
在服务器上启用 TLS/SSL,以便客户端可以使用 wss:// 或 https:// 进行连接。
property SSL: Boolean read FSSL write FSSL default False;
False
将 SSL 设置为 True 以接受安全连接。您还必须在 SSLOptions 中配置证书材料(CertFile、KeyFile、RootCertFile、Password),并将 SSLOptions.Port 设置为 TLS 端口。同一服务器可以通过添加多个 Bindings 条目并保持 SSL=True 来同时服务明文和加密端点;服务器仅将 TLS 处理程序自动附加到安全端口。证书必须以 PEM 格式提供。
oServer := TsgcWebSocketHTTPServer.Create(nil);
oServer.SSL := true;
oServer.SSLOptions.CertFile := 'c:\certificates\mycert.pem';
oServer.SSLOptions.KeyFile := 'c:\certificates\mycert.pem';
oServer.SSLOptions.RootCertFile := 'c:\certificates\mycert.pem';
oServer.SSLOptions.Port := 443;
oServer.Port := 443;
oServer.Active := true;