Delphi 11中是否存在SSL行为变化?

发布于 2025-01-22 14:09:41 字数 341 浏览 0 评论 0原文

几个月来,我一直使用delphi 10.3提供的idwebsocketsimpleclient单元,

以前,连接到服务器的组件启动了HTTP升级到WebSocket连接,接收了101-切换协议响应并开始进行通信。现在,有了Delphi 11,我收到了400个不良要求。内部错误消息显示“普通的HTTP请求已发送到HTTPS端口”。在这两种情况下,相同的OPENSL DLL文件都位于应用程序可执行文件夹中,并且使用TIDSSLIOHANDLESOCKETCOPESLSL组件。

在这一点上,由于程序代码尚未更改,我真的很困惑为什么会发生这种情况。这让我想知道是否有任何行为改变了所涉及的Indy单位。我不知道从哪里开始调查。有人可以帮忙吗?

For months, I have used the IdWebSocketSimpleClient unit with Delphi 10.3 provided here to setup a Websocket connection to the discord gateway API. Now, that I changed to Delphi 11, the same code shows another behaviour.

Previously, the component connected to the server, initiated an HTTP Upgrade to a websocket connection, received the 101 - switching protocols response and started to communicate. Now, with Delphi 11, I receive a 400 - Bad request. The inner error message shows "The plain HTTP request was sent to HTTPS port". In both scenarios, the same OpenSSL dll files are sitting in the applications executable folder and an TIdSSLIOHandlerSocketOpenSSL component is used.

At this point, I am really confused why this is happening, as the programs code hasn't been changed. This makes me wonder if there have been any behaviour changes to the indy units involved. I have no clue where to even start my investigation. Can someone help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扎心 2025-01-29 14:09:41

Delphi 10.3于2018年底发布。对tidssliohandlersocketbasebase类进行了更改,以修复其PassThrough属性的错误,该错误正在初始化为>> 。 false应该将其初始化为true而不是(现在是当前行为)。

因此,这很容易考虑您看到的行为,因为错误消息抱怨发送到安全的HTTPS端口的无抵押HTTP消息(因为PassThrough可能是true >)。

该更改并不影响大多数Indy组件,因为它们在内部根据需要明确设置PassThrough(通常基于usetls属性或请求的特定URL协议/端口)。但是,更改确实会直接影响使用tidtcpclient的最终用户代码(因为此WebSocket代码正在执行)。在这种情况下,用户(并且始终)负责根据需要设置PassThrough,但是此WebSocket代码没有这样做。连接到安全URL时,假设 PassTrough已将用户设置为false,然后tidsimplewebsocketclient.connect()< /code>被调用,而不是强迫 falsePassThrough肯定不会设置为false,如果tidsimplewebsocketclient需要自动创建自己的ssliohandler对象。

tidsimplewebsocketclient.connect() 应该在内部设置 passthrough:= not lsecure; 在调用继承>继承的连接。我已将其报告为作者的错误:

#10:tidsimplewebsocketclient tls tls tls tls错误-400 BAD -400 BAD请求,普通的HTTP请求已发送到HTTPS端口

同时,在作者修复此错误之前,您可以将自己的ssliohandler组件分配给tidsimplewebsocketclient.iohandler < /code>属性并将其设置为passThrough = false在调用tidsimplewebsocketclient.connect()带有wss: url。

Delphi 10.3 was released in late 2018. There was a change made to the TIdSSLIOHandlerSocketBase class in late 2019, to fix a bug where its PassThrough property was being initialized to False when it should have been initialized to True instead (which is now the current behavior).

So, that could easily account for the behavior you are seeing, as the error message is complaining about an unsecured HTTP message being sent to a secure HTTPS port (because PassThrough is likely True).

That change did not affect most Indy components, as internally they explicitly set PassThrough as needed (typically based on a UseTLS property, or a specific URL protocol/port being requested). But, the change does affect end-user code that uses TIdTCPClient directly (as this WebSocket code is doing). In that case, the user is (and always has been) responsible for setting PassThrough as they need, but this WebSocket code is not doing that. When connecting to a secure URL, it assumes that PassThrough has been set to False by the user before TIdSimpleWebSocketClient.Connect() is called, rather than forcing it to False. And PassThrough is certainly not being set to False if TIdSimpleWebSocketClient needs to auto-create its own SSLIOHandler object.

TIdSimpleWebSocketClient.Connect() should internally be setting PassThrough := not lSecure; before calling inherited Connect. I have reported this as a bug to the author for you:

#10: TIdSimpleWebSocketClient TLS error - 400 Bad request, the plain HTTP request was sent to HTTPS port

In the meantime, until the author fixes this bug, you can simply assign your own SSLIOHandler component to the TIdSimpleWebSocketClient.IOHandler property and set it to PassThrough=False before calling TIdSimpleWebSocketClient.Connect() with a wss: URL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文