Skip to content

fix(gated): honor the configured hub TLS server name - #187

Merged
TN019 merged 5 commits into
mainfrom
fix/gated-tls-server-name
Dec 2, 2026
Merged

TN019 merged 5 commits into
mainfrom
fix/gated-tls-server-name

Conversation

@TN019

@TN019 TN019 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Why

config/gated.env.example documents GATEPOST_TLS_SERVER_NAME, but nothing read it. Gates always checked the hub certificate against the fixed name hub.venue.lan, and the hub's TLS ticket listener only accepted that name in the Host header. A venue whose hub certificate carries another name could not use TLS, and the documented setting had no effect.

What changed

  • libgate: shared DNS host-name validation (length 1–253, labels 1–63 of letters, digits and hyphens, no leading or trailing hyphen, no empty labels or trailing dot).
  • gate-hub: reads GATEPOST_TLS_SERVER_NAME (default hub.venue.lan), refuses to start on an invalid value, and its TLS ticket listener accepts exactly <name> and <name>:8444. The plaintext listener's GATEPOST_STATUS_HOSTS rules are unchanged.
  • gated: reads the same setting with the same default and validation, and uses it for SNI, the certificate host check, the HTTPS ticket URL and the connect-to mapping.
  • Tests: validator unit tests; gate and hub end-to-end cases for a matching name, a mismatched name and invalid values; a hub case showing that with a custom name the TLS listener still refuses hub.venue.lan:8444 and 10.77.20.10:8444. Existing tests are unchanged.
  • Docs: both example environment files, the operations and protocol guides (English and Chinese) and both changelogs. Hub and gates must set the same name, matching the hub certificate.

How to verify

In the build container, all four presets: cmake --preset <p> && cmake --build --preset <p> && ctest --preset <p> --output-on-failure for debug, release, asan and tsan: 67/67 tests passed in each. clang-format --dry-run -Werror over C sources and headers: clean.


背景

config/gated.env.example 里写了 GATEPOST_TLS_SERVER_NAME,但代码从不读取。闸机总是按固定名称 hub.venue.lan 核对 hub 证书,hub 的 TLS 取票端口也只接受这个名称作为 Host。hub 证书用别的名称时无法使用 TLS,文档里的这个设置也不起作用。

改动

  • libgate:闸机和 hub 共用的 DNS 主机名校验(总长 1–253,每段 1–63 个字母、数字或连字符,不能以连字符开头或结尾,不能有空段或结尾的点)。
  • gate-hub:读取 GATEPOST_TLS_SERVER_NAME(默认 hub.venue.lan),值不合法时拒绝启动;TLS 取票端口只接受 <名称> 和 <名称>:8444。明文端口的 GATEPOST_STATUS_HOSTS 规则不变。
  • gated:读取同一设置,默认值和校验相同,用于 SNI、证书主机名核对、HTTPS 取票地址和 connect-to 映射。
  • 测试:校验函数的单元测试;闸机和 hub 在名称一致、不一致和不合法时的端到端用例;hub 在自定义名称下仍拒绝 hub.venue.lan:8444 和 10.77.20.10:8444 的用例。原有测试不变。
  • 文档:两个示例环境文件、运维和协议文档(中英文)以及两份 CHANGELOG。hub 和闸机必须配置同一名称,并与 hub 证书一致。

怎么验证

在构建容器里对 debug、release、asan、tsan 四个预设分别执行 cmake --preset <p> && cmake --build --preset <p> && ctest --preset <p> --output-on-failure:每个预设 67 个测试全部通过。对 C 源文件和头文件运行 clang-format --dry-run -Werror:没有问题。

@TN019
TN019 merged commit 6a6d3ce into main Dec 2, 2026
5 checks passed
@TN019
TN019 deleted the fix/gated-tls-server-name branch December 2, 2026 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant