Blazor 服务器:使用 HTTPS 保护传输中的信息:WebSocket 是否不够安全?
Blazor 服务器开发非常棒!我担心的问题之一是通过 SignalR/WebSockets 发送数据的安全性。
根据我的理解,客户端和服务器之间的通信是:
- 用户采取操作,例如单击按钮
- Javascript 创新了与服务器的 WebSocket 通信
- 服务器用我返回的数据进行响应
- Javascript 更改页面 (DOM)
从 Chrome 开发者工具中,我可以在 websocket 上看到这种情况发生,即 wss://localhost/_blazor?id=XXXXXXXXXXXXXXX
。由于 websocket 是 wss://
我认为通信是安全的并且确保了完整性和机密性,例如中间人攻击等
那么为什么 Microsoft 建议更改为 Blazor 服务器威胁迁移文档中的“始终使用 HTTPS”?
通过 HTTPS 保护传输中的信息
Blazor Server 使用 SignalR 在客户端和 服务器。 Blazor 服务器通常使用 SignalR 的传输 协商,通常是 WebSocket。
Blazor 服务器不确保数据的完整性和机密性 服务器和客户端之间发送的数据。始终使用 HTTPS。
Blazor Server development is great! One of my concerns is with the security of data being sent through SignalR/WebSockets.
From my understanding the communication between client and server is:
- Action is taken by user e.g. clicks button
- Javascript innovates the WebSocket communication with my server
- Server responds with data that I've returned
- Javascript changes the page (DOM)
From Chrome developer tools I can see this happening on the websocket i.e. wss://localhost/_blazor?id=XXXXXXXXXXXXXX
. As the websocket is wss://
I thought communication was secure and ensured integrity and confidentiality e.g. man-in-the-middle attacks etc
So why has Microsoft advised to "Always user HTTPS" in their Blazor Server Threat Migration documentation?
Protect information in transit with HTTPS
Blazor Server uses SignalR for communication between the client and
the server. Blazor Server normally uses the transport that SignalR
negotiates, which is typically WebSockets.Blazor Server doesn't ensure the integrity and confidentiality of the
data sent between the server and the client. Always use HTTPS.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢布伦南在评论中回答我的问题。
该警告只是一般文本。文档中的两个声明是相互独立的。
下面解释了 Blazor Server 通常用于客户端和服务器之间通信的机制,即 WebSockets
下面指出在客户端和服务器之间通信时应始终使用安全协议,即 HTTPS
我认为 Microsoft 指的是使用标准 API (HTTP/2) 端点来确保完整性和机密性。正如 Brennan 指出的 - WebSockets 是 HTTP/1.1 的扩展,因此可以使用 HTTPS。
希望这对未来的人们有所帮助。
Thank you to Brennan for answering my question in the comments.
The warning is just general text. The two statements on the documentation are independent of each other.
The below explains the mechanism Blazor Server typically uses for communication between client and server i.e. WebSockets
The below states you should always use a secure protocol when communicating between client and server i.e. HTTPS
I assumed Microsoft was referring to using standard API (HTTP/2) endpoints to ensure integrity and confidentiality. As Brennan pointed out - WebSockets is an extension of HTTP/1.1, and thus can use HTTPS.
Hopefully, this helps people in the future.