THTTPClient 访问仅 TLS 1.3 的站点会导致错误
此代码:
uses
System.Net.HttpClient;
procedure TForm2.Button1Click(Sender: TObject);
var
LHTTP: THTTPClient;
LResponse: IHTTPResponse;
begin
LHTTP := THTTPClient.Create;
try
LHTTP.SecureProtocols := [THTTPSecureProtocol.TLS13];
LResponse := LHTTP.Get('https://tls13.1d.pw'); // TLS 1.3 ONLY site
if LResponse.StatusCode = 200 then
ShowMessage('TLS 1.3 worked');
finally
LHTTP.Free;
end;
end;
结果:
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class ENetHTTPClientException with message 'Error sending data: (12175) A security error occurred'.
---------------------------
Break Continue Help Copy
---------------------------
使用 Windows 10(相同的代码适用于 Windows 11)。我已进入 Windows 中的“Internet 选项”设置并启用了 TLS 1.3,但这并不能解决问题。
我还需要做什么吗?
This code:
uses
System.Net.HttpClient;
procedure TForm2.Button1Click(Sender: TObject);
var
LHTTP: THTTPClient;
LResponse: IHTTPResponse;
begin
LHTTP := THTTPClient.Create;
try
LHTTP.SecureProtocols := [THTTPSecureProtocol.TLS13];
LResponse := LHTTP.Get('https://tls13.1d.pw'); // TLS 1.3 ONLY site
if LResponse.StatusCode = 200 then
ShowMessage('TLS 1.3 worked');
finally
LHTTP.Free;
end;
end;
Results in:
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class ENetHTTPClientException with message 'Error sending data: (12175) A security error occurred'.
---------------------------
Break Continue Help Copy
---------------------------
Using Windows 10 (The same code works on Windows 11). I've gone into the Internet Options settings in Windows and enabled TLS 1.3, however that does not resolve the issue.
Anything else I need to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据 WinHTTP 错误消息 文档:
不幸的是,
THTTPClient
不为您提供使用此类回调的访问权限,但它确实使用内部回调来捕获其SecureFailureReasons
属性。所以您可以检查以获取更多信息。您确定在 Windows 10 上启用了 TLS 1.3 吗?您使用的是 1903 版本或更高版本吗?早期版本不支持 TLS 1.3。
如何在 Windows 10 中启用 TLS 1.3
Per the WinHTTP Error Messages documentation:
Unfortunately,
THTTPClient
does not provide access for you to use such a callback, but it does use an internal callback to capture the reason forERROR_WINHTTP_SECURE_FAILURE
in itsSecureFailureReasons
property. So you can check that for more info.Are you sure you enabled TLS 1.3 on Windows 10? Are you using build 1903 or later? Earlier builds do not support TLS 1.3.
how to enable TLS 1.3 in windows 10