1

我正在开发一个需要升级才能在 Windows-11 上使用 TLS 1.3 的 TLS 客户端。有没有人使用 SChannel API 成功实现了 TLS 1.3?

根据 Microsoft 下面的链接 TLS 1.3 在 win-11 和 server-2022 中受支持

https://docs.microsoft.com/en-us/windows/win32/secauthn/protocols-in-tls-ssl--schannel-ssp-

下面为 TLS1.3 添加了代码片段:

#define SECURITY_PROTOCOL_TLSV13 0x00
securityInfo->bySecurityProtocol = SECURITY_PROTOCOL_TLSV13;
sChannelCred->grbitEnabledProtocols =SP_PROT_TLS1_3_CLIENT;

status = pMyFunTab->**AcquireCredentialsHandleA**(NULL, UNISP_NAME_A, SECPKG_CRED_OUTBOUND, NULL, &sChannelCred, NULL, NULL, phCred, &ts);

返回状态 = SEC_E_ALGORITHM_MISMATCH (0x80090331)

**error details: Secure connection failed. An error occurred while trying to connect to the host, error code 0x80090331. The client and server cannot communicate, because they do not possess a common algorithm.**

api链接:

https://docs.microsoft.com/en-us/windows/win32/api/sspi/nf-sspi-acquirecredentialshandlea https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/SecAuthN/acquirecredentialshandle --schannel.md


尝试了以下更改以修复相同的问题:

Windows 版本测试:windows 11 21h2 os build 22000.434

注册表更改:如下所示链接: 如何在 Windows 10 中启用 TLS 1.3

任何建议或 C++ 代码的小样本都非常感谢,以及任何可以帮助我了解客户问题的建议。

仅供参考:我没有使用 CURL LIB。

谢谢

问候:阿杰·贾斯瓦尔

4

3 回答 3

1

有一个支持 schannel tls 1.3 的 curl 拉取请求

你可以看看https://github.com/curl/curl/pull/7784

于 2022-01-19T10:55:35.307 回答
1

Gilles,您是否在 Win10 或 Win11 上使用 schannel 作为 SSL 后端尝试了最新的 curl 7.81.0?以下是我看到的。

curl -vI --tls-max 1.3 https://www.google.com
*   Trying 142.251.35.164:443...
* Connected to www.google.com (142.251.35.164) port 443 (#0)
* schannel: disabled automatic use of client certificate
* schannel: TLS 1.3 is not yet supported
* Closing connection 0
curl: (35) schannel: TLS 1.3 is not yet supported
于 2022-01-25T06:08:38.820 回答
0

我在 Win11 中遇到了同样的问题,但下面的相同代码在 Win10 中有效。请注意,我的 Win11 的注册表中已启用 TLS 1.3。

     SCHANNEL_CRED SchannelCred;
     CredHandle hClientCreds;
     TimeStamp tsExpiry;
    
     PSecurityFunctionTable sspi = InitSecurityInterface();
    
     ZeroMemory(&SchannelCred, sizeof(SchannelCred));
     SchannelCred.dwVersion = SCHANNEL_CRED_VERSION;
     SchannelCred.grbitEnabledProtocols = SP_PROT_TLS1_3_CLIENT;
     SchannelCred.dwFlags |= SCH_CRED_MANUAL_CRED_VALIDATION | SCH_CRED_NO_DEFAULT_CREDS | SCH_USE_STRONG_CRYPTO;
    
     SECURITY_STATUS Status = sspi->AcquireCredentialsHandle(NULL,
         (SEC_CHAR*)UNISP_NAME_A,
         SECPKG_CRED_OUTBOUND,
         NULL,
         &SchannelCred,
         NULL,
         NULL,
         &hClientCreds,
         &tsExpiry);

后来发现Win11中TLS 1.3需要使用SCH_CREDENTIALS结构而不是SCHANNEL_CRED结构。

于 2022-01-27T01:37:45.450 回答