Delphi 11中是否存在SSL行为变化?
几个月来,我一直使用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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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>被调用,而不是强迫
false
。PassThrough
肯定不会设置为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 itsPassThrough
property was being initialized toFalse
when it should have been initialized toTrue
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 likelyTrue
).That change did not affect most Indy components, as internally they explicitly set
PassThrough
as needed (typically based on aUseTLS
property, or a specific URL protocol/port being requested). But, the change does affect end-user code that usesTIdTCPClient
directly (as this WebSocket code is doing). In that case, the user is (and always has been) responsible for settingPassThrough
as they need, but this WebSocket code is not doing that. When connecting to a secure URL, it assumes thatPassThrough
has been set toFalse
by the user beforeTIdSimpleWebSocketClient.Connect()
is called, rather than forcing it toFalse
. AndPassThrough
is certainly not being set toFalse
ifTIdSimpleWebSocketClient
needs to auto-create its ownSSLIOHandler
object.TIdSimpleWebSocketClient.Connect()
should internally be settingPassThrough := not lSecure;
before callinginherited 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 theTIdSimpleWebSocketClient.IOHandler
property and set it toPassThrough=False
before callingTIdSimpleWebSocketClient.Connect()
with awss:
URL.