SChannel TLS 后端

SChannel(iohSChannel)是 sgcWebSockets 的 Windows 原生 TLS 传输。它使用内置于 Windows 的 Microsoft Secure Channel(SSPI)栈,因此无需额外部署任何东西,也没有 OpenSSL DLL 需要随附或打补丁。通过将 TLSOptions.IOHandler 设置为 iohSChannel 来启用它。

← 所有 TLS 后端

SChannel (iohSChannel)

Microsoft 的原生 TLS 栈,内置于 Windows。无需部署任何库。

SChannel 是 Microsoft 的原生 TLS 实现,即通过 SSPI 暴露的 Secure Channel 提供程序。它是 Windows 本身的一部分,因此当你选择此后端时,没有 OpenSSL 运行时需要打包,没有 DLL 需要与你的构建进行版本匹配,也没有第三方库需要在披露漏洞时打补丁。信任、协议支持和证书处理全部来自操作系统。

由于 SChannel 从 Windows 证书存储读取,证书和根机构由操作系统集中管理,并通过 Windows Update 刷新。TLS 1.3 在 Windows 11 和 Windows Server 2022 及更高版本上可用。这使得 SChannel 非常适合希望使用原生 TLS 并将部署占用降到最低的 Windows 桌面和服务器应用。

SChannel 仅限 Windows。在 Linux、macOS、iOS 或 Android 上使用 TLS 时,你需要使用 OpenSSL 或其中一种原生移动后端。由于每个后端都共享相同的 TLSOptions API,Windows 构建可以运行 SChannel,而同一套代码库在其他平台上针对 OpenSSL 或原生后端,各平台之间只有 IOHandler 这一行不同。

启用 SChannel

将 TLSOptions.IOHandler 设置为 iohSChannel。无需部署任何库。

uses
  sgcWebSocket, sgcWebSocket_Types;
// ...
WSClient.TLS := True;
WSClient.TLSOptions.IOHandler := iohSChannel;
WSClient.TLSOptions.VerifyCertificate := True;
WSClient.Host := 'your.server.com';
WSClient.Port := 443;
WSClient.Active := True;
WSClient->TLS = true;
WSClient->TLSOptions->IOHandler = iohSChannel;
WSClient->TLSOptions->VerifyCertificate = true;
WSClient->Host = "your.server.com";
WSClient->Port = 443;
WSClient->Active = true;

无需部署任何东西

SChannel 随 Windows 一起提供,因此部署占用是所有后端中最小的。

没有 OpenSSL DLL

你的应用无需随附任何 libssl 或 libcrypto。没有额外的东西需要进行版本匹配或打补丁。

Windows 证书存储

证书和受信任根来自操作系统存储,集中管理并通过 Windows Update 刷新。

TLS 1.3

TLS 1.3 在 Windows 11 和 Windows Server 2022 及更高版本上可用,较旧的 Windows 回退到 TLS 1.2。

仅限 Windows

SChannel 运行在 Windows 上。在 Linux、macOS、iOS 和 Android 上请使用 OpenSSL 或原生移动后端。

版本说明

SChannel(iohSChannel)包含在 sgcWebSockets 的 Professional 和 Enterprise 版本中。它不属于 Standard 版本。完整细分请参见功能矩阵

原生 Windows TLS,无需 DLL

下载免费试用版,在 Windows 上运行 TLS,无需发布任何 OpenSSL 库。