Skip to content

fix: catcher-ws / catcher-napi-ws 编译时未启用 TLS — wss:// 连接全部失败 #4

Description

@eric8810

Bug 描述

@eric8810/catcher-napi-ws 预编译 binary 没有 TLS 支持,所有 wss:// 连接立即失败。

根因

catcher-wsCargo.tomltokio-tungstenite = "0.29" 没有启用任何 TLS feature。

tokio-tungstenite 默认只启用 connect + handshake不包含 TLS。需要显式启用 native-tlsrustls-tls-* feature 才能支持 wss://

代码中使用了 tokio_tungstenite::MaybeTlsStreamconnect_async_with_config,在没有 TLS 编译支持时,MaybeTlsStream 退化为 plain TCP,wss:// URL 会直接报错。

影响

  • 所有 wss:// WebSocket 连接
  • 仅影响预编译 binary(本地 cargo build 也不含 TLS)
  • ws://(非加密)不受影响

修复

  1. catcher-ws/Cargo.toml

    • 添加 [features]default = ["rustls-tls"]
    • rustls-tls = ["tokio-tungstenite/rustls-tls-webpki-roots"]
    • native-tls = ["tokio-tungstenite/native-tls"](备选)
    • tokio-tungstenite 改为 default-features = false,显式启用 connect + handshake
  2. catcher-napi-ws/Cargo.toml

    • catcher-ws 依赖显式加 features = ["rustls-tls"]
  3. TLS 方案选择 rustls-tls-webpki-roots(与 catcher-http 的 rustls 方案一致),交叉编译友好。

验证

编译后可以看到 rustlstokio-rustls 被正确引入为依赖(之前完全没有编译过)。

cargo check -p catcher-ws -p catcher-napi-ws
# 现在 rustls 会被编译进来
cargo test -p catcher-ws  # 单元测试通过

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions