Skip to content

Native TLS web server: support SNI / multiple certificates on a single :443 listener #600

Description

@logbie

Summary

The native TLS web server (listen on port 443 secured with certificate <cert> and key <key>) binds a single certificate/key per listener and has no SNI support — it cannot select a certificate based on the TLS ClientHello server name. This means one WFL process can serve HTTPS for only one certificate on :443.

Current behavior

  • In src/interpreter/mod.rs, the secured listener builds a rustls ServerConfig from one PEM chain + one key (single-cert). There is no ResolvesServerCert / SNI resolver, and two secured listeners cannot both bind :443.
  • A request arriving with a different SNI still gets the one loaded certificate, so any other hostname fails validation.

Why it matters (real deployment)

This surfaced deploying wfl-web (the WFL site, now the Scriptorium CMS) on a single box that needs to serve wfl.fyi (behind Cloudflare, using a Cloudflare Origin cert) while also answering for the retired webfirstlanguage.com to 301-redirect it. With only one cert per :443, the box cannot present a valid cert for both names at once. The workaround was to move the old domains onto Cloudflare and redirect at the edge — but a WFL server that terminates its own TLS for multiple hostnames (e.g. apex + a redirect domain, or multi-tenant sites) has no in-language option today.

Proposed

Add SNI / multi-certificate support to the secured web server, e.g.:

  • Allow multiple listen ... secured with certificate <cert> and key <key> bindings on the same port, selected by SNI; or
  • A cert-map form, e.g. listen on port 443 secured with certificates cert_map as web_server where cert_map maps hostname -> {cert, key}; or
  • Wire a rustls ResolvesServerCert behind the existing syntax so multiple certs can be registered.

A sensible default (first/only cert as fallback for unmatched SNI) would keep single-cert setups unchanged.

Environment

  • WFL 26.7.27 (also present on 26.7.21), native TLS web server, rustls.
  • Reported from the wfl.fyi / webfirstlanguage.* deployment on the hostinger box.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions