Skip to content

feat(tunnel): add optional encryption for non-TLS Aether-tunnel traffic #529

@RWDai

Description

@RWDai

背景

当前 tunnel 节点会根据 aether_url 构造回连协议:

  • https://... -> wss://.../api/internal/proxy-tunnel,Aether ↔ tunnel 之间由 TLS 保护。
  • http://... -> ws://.../api/internal/proxy-tunnel,Aether ↔ tunnel 之间不是 TLS,会导致 tunnel 帧明文传输。

这里讨论的重点是 Aether ↔ tunnel 这段 tunnel 通道本身。origin/provider 目标是否是 HTTPS 与这个需求无关;即使 origin 是 HTTPS,只要 Aether ↔ tunnel 使用 ws/http,Aether 发给 tunnel 的请求元数据、headers、body,以及 tunnel 返回的响应数据,在这段通道上仍然缺少 TLS 保护。

需求

为 tunnel 增加一个可配置功能:当 Aether ↔ tunnel 使用非 TLS 通道(ws:// / http://)时,可以对 tunnel 帧或 payload 做应用层加密封装,避免这段链路裸明文传输。

示例配置名可以是:

encrypt_non_tls_tunnel = true
# 或 tunnel_payload_encryption = true

setup 中也应提供对应选项,例如:

Encrypt Aether <-> tunnel traffic when the tunnel connection is not TLS?

期望行为

  1. 该功能是一个真实的加密开关,不只是 warning。
  2. 开启后,即使底层连接仍是 ws://,Aether ↔ tunnel 之间承载的 tunnel 请求/响应内容也不应以可读明文出现。
  3. 加密范围应覆盖 tunnel 数据帧中的敏感内容,例如请求 URL、headers、body、响应 headers/body 等。
  4. 该功能应兼容现有 wss:// 模式;如果底层已经是 TLS,可以允许关闭、跳过或作为双层加密选项,由实现设计决定。
  5. setup 和文档需要明确说明:这个选项保护的是 Aether ↔ tunnel 这一段,不讨论也不改变 tunnel ↔ origin/provider 的协议选择。

非目标

  • 不讨论 origin/provider 是否为 HTTPS。
  • 不要求把 origin HTTP 自动升级成 HTTPS。
  • 不要求强制 aether_url 必须是 https://
  • 不只是提示用户 http/ws 有风险,而是提供可配置的加密能力。

可能实现方向

  • 在 tunnel protocol 的 RequestHeaders / RequestBody / ResponseHeaders / ResponseBody payload 层增加加密封装。
  • 增加协议版本协商,只有 Aether 和 tunnel 都支持时才启用。
  • 使用管理 token 派生会话密钥,或增加独立的 tunnel encryption key。
  • 为每条 WebSocket 连接或每个 stream 增加 nonce/序号,避免重放或 nonce 复用。
  • 保留向后兼容:未开启或旧版本节点继续使用现有明文 frame 协议。

验收标准

  • 配置文件和 setup 中有可持久化的“非 TLS tunnel 通道加密”选项。
  • 开启后,ws:// Aether ↔ tunnel 通道中的敏感 tunnel payload 不再是可读明文。
  • Aether 和 tunnel 两端完成协议能力协商,版本不兼容时给出清晰错误或自动回退策略。
  • 文档明确区分:
    • wss:// = 传输层 TLS;
    • ws:// + tunnel payload encryption = 非 TLS 传输上的应用层加密;
    • tunnel ↔ origin/provider 不属于本 issue 范围。
  • 测试覆盖开启/关闭该选项,以及非 TLS tunnel 下请求和响应仍能正常转发。

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