From dba6668dc9c9515edc2af5cb302aca9c947be24e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Sat, 28 Nov 2026 21:21:33 +0100 Subject: [PATCH] v0.43.1 --- CHANGELOG.md | 3 ++- SHA256SUMS | 24 +++++++++--------- docs/CERTIFICATES.md | 2 +- langs/en_US.json | 6 +++-- langs/pl_pl.json | 6 +++-- src/admin/openapi.json | 7 ++++++ src/admin/status.rs | 42 +++++++++++++++++++++++++++++-- src/admin/web/app/runtime.js | 7 +++--- src/admin/web/css/10-base.css | 4 +++ src/admin/web/css/40-editors.css | 25 ++++++++++++++++++ src/admin/web/css/50-settings.css | 4 +-- src/tls/tests.rs | 22 ++++++++++++++++ src/tls/types.rs | 29 +++++++++++++++++++++ 13 files changed, 156 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebc6fdc..54f0577 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,12 +37,13 @@ Release history focused on **features, settings, default behavior, compatibility - **Overview:** five tiles (requests, errors with share, response/request bytes, mean latency, dropped samples) and a strip with the collected dimensions and a link to the logging settings. Methods, status classes and cache outcomes are 100 % stacked bars with counts and shares instead of donuts. Top paths and top client IPs come with shares and an "other" row. - **Clients / Requests / Delivery:** the same lists as before (countries, User-Agents, client IPs, paths, routes, methods, statuses, cache, volume) as ranked lists with shares. Clicking a value still copies it. - **Missing data:** when country collection is off or GeoIP is missing, the panel shows one sentence with a settings link instead of an empty chart. -- **Certificates — Docker vhosts:** "Where it is used" also lists Docker vhosts that use the certificate (agent · service, hostnames, coverage, a mismatch warning when the agent allows it) and **Open** goes to Docker vhosts with the service found. They are read-only here because a Docker vhost takes its certificate from its agent's allowed list. The usage count, the "Assigned" details line, the Assignments tile (now "· N Docker") and the search include them, and Delete stays blocked while a Docker vhost uses the certificate. `/api/docker` routes now report `certificate_id` and `certificate_mismatch`, chosen by the same rule as the generated Docker vhost. "Docker agents allowing it" → **Open** now goes straight to Settings → Docker agents. +- **Certificates — Docker vhosts:** "Where it is used" also lists Docker vhosts that use the certificate (agent · service, hostnames, coverage, a mismatch warning when the agent allows it) and **Open** goes to Docker vhosts with the service found. Docker vhosts of agents in *Automatic* certificate mode (or whose selected certificates do not cover the hostnames) are listed under the certificate SNI really serves for their hostnames, marked **SNI auto**; the names are read from the certificate file when the configuration does not store them, like the TLS listener does. They are read-only here because a Docker vhost takes its certificate from its agent's settings. The usage count, the "Assigned" details line, the Assignments tile (now "· N Docker") and the search include them, and Delete stays blocked while a Docker vhost uses the certificate. `/api/docker` routes now report `certificate_id` and `certificate_mismatch`, chosen by the same rule as the generated Docker vhost, and `sni_certificate_ids` for routes without a selected certificate. "Docker agents allowing it" → **Open** now goes straight to Settings → Docker agents. - **Certificates — filters:** new **Assigned** filter; clicking the Assignments tile selects it (it used to select **Unassigned**). - **Changing IDs everywhere:** redirects, 404 hosts, streams, Web Services, FastCGI profiles, ACL profiles, listeners, Docker agents and certificates show the ID like Vhosts do (value with **Change**). An existing ID can be renamed while nothing references it; when it is used (for example a Web Service by a vhost, a FastCGI profile by a Web Service, an ACL profile by a vhost or Docker agent, a listener by a vhost/redirect/404 host, a certificate by a vhost, the default certificate or a Docker agent) the field is locked and the panel lists where it is used. Renaming checks for duplicates; renaming a certificate keeps its files. FastCGI profiles, Web Services and ACL profiles could not be renamed before even when unused. - **ACL profiles:** the tab opens with the profile list (search, New profile) instead of an empty editor; a profile opens in a dialog like redirects and 404 hosts, with a prompt before closing unsaved changes. Each profile is a card with its mode, where it is attached, default action, IP/DNS rules and country policy. The "attached to" information now also counts vhosts that use the profile through their security settings (they were shown as unused before, while Delete was still refused by the configuration). - **Default responses:** "Unmatched path" reads "Unmatched path (404 response)". - **Streams:** in the stream editor the Protocol field starts on its own row. +- **Field alignment:** in ACL profile IP/CIDR exceptions the Action badge, address type, address and Delete are on one line with equal heights. A text field next to a taller field (for example Display name next to a locked Profile ID with its explanation) no longer stretches to the height of the row; FastCGI profile and Docker agent fields use the standard field height. - **Documentation reader:** table cells no longer split short words such as "Vhosts" over several lines when a neighbouring column has long text. - **Translations:** ID field texts ("Generated from the name", "Change", lock reasons) follow a language change without reload. - **Admin panel internals:** vhosts, redirects and 404 hosts expose `edit(id)` so other views (Certificates → Where it is used) can open their editors. diff --git a/SHA256SUMS b/SHA256SUMS index 239929a..7bd01f5 100644 --- a/SHA256SUMS +++ b/SHA256SUMS @@ -2,7 +2,7 @@ 4140a2956264b44f259e6a37fc00ba02097bbe68b09296e04d3d243c1287129b .env.example 0a5e87541831edca0e7164c6469dba01a8a7053ab14dbfb8019c83e4db10edc2 .gitignore 903ca521af6ef7e54f83dc0b4b0436d116c88f064c36f0317b689b7cce79ab27 AGENTS.md -5bf17de4f670750a1fea956aacbf7bf9b210b2e7ccdd61bd6462940caeb7bbda CHANGELOG.md +a4283c25bbd1017cd2df6aac0ebfd5ae793b72e1d51354dd9198ccfcc0af7dc2 CHANGELOG.md 062486dade9ca64ed26710775cc991489c75dc475f624a334c0fa881be526e32 Cargo.lock 216f2434431a6eb3b717b8cd5a783f5dda4f60f281b96ffd512919218953e6a6 Cargo.toml 9141c5c5a0923b08ec1e746a7ed10c20ba0a29e67f4302698fa1c2913c6ee66f Dockerfile @@ -43,7 +43,7 @@ c4728da70d60d193c5c348d90c7c26ba1756d3459052a10a121f9be69a4dd18a docs/ACCESS.md 728b15b9825f547f34c4121219784798dd046fbbdd72ece8906d0cd77e8efc64 docs/BACKUP.md bfe96dd91dfc6e07918a662d98b036f12ceb011a5aa8381b3778bd0c964b19ab docs/CACHE.md 51d34823d139ff3b0b8e1cf1a31850746be5ed7da847a2cca51be36fd5f7733a docs/CACHE_TEMPLATE_LIBRARY.md -6cd6abb39b1867b4c30cdebca90caf992589bebdf7f2076274e912508e60cd2d docs/CERTIFICATES.md +529be976b56a18c947c7e451cc7748fa40ea964f30a1d4c49c5a8155e614594b docs/CERTIFICATES.md 81df6715e2f07617fe0bbb0960c4d5bdac28cf665ce7297fa3768118e6ab28ba docs/CONFIGURATION.md 32b076170bc2669d676ec78a067efec461a0072ddf8f68df1e7655b208e1c9c0 docs/CUSTOM_LOCATIONS.md 7b286e85330fad398fc6f9df1b894e004a42fb33ab7168eb93f87220a3bf5503 docs/DASHBOARD.md @@ -138,8 +138,8 @@ e9cbb0224c4a3d23a6019ba557e0cd568c1ad5e1582ff1e335fb7d99b7a1055d integrations/r 3d44e4080206c71d3ffdbcbd2f50c43cb227bc38e096801f07f818388a49a405 integrations/routeros-oci-build/build-routeros-oci.sh 3f267cafa16006e5456ade78ee2d5fae02cc7ce747839523068ffd8d7c98798a integrations/routeros-oci-build/docker-entrypoint.sh ae2ee2887fcba096d0de25edcc18faa1ffec35759274518db1bf6d6982f7176c langs/README.md -47a8bec030c6123a9b8543791a9a2c3ffc15f0749450bdc775bf2e620c4c4a07 langs/en_US.json -f7e877047212f425e1c75334d0e346b4a0b7aa3b08e7b367987dc5ba775bf2f5 langs/pl_pl.json +244e289233692551fe2bf6a5dedf5493600726ef45e8e0010def675ea0eca5cd langs/en_US.json +b758ea88a661df1c2a2f53a52b0dd5b33035f6993bef71ecd0781a6b4bbda8ca langs/pl_pl.json 80d1fd9cc05d51235f6a871f48cbad1440b2095609c335583674829f1df08a42 make_zip.py 27790aa2c6b5be577fe3f34876385624dca824162fe96ee313845f0389d4674a migrations/0002_admin.sql d28a83df192518a8b7c01383b683bd34b84307a6e839a05bf917af69d0c87f09 migrations/0003_certificate_renewals.sql @@ -213,7 +213,7 @@ ab0449d253fd776ae1658a92f2d7dd509ee18ebdecdec085f120733b2f08e740 src/admin/file a2cdd534cb989d5232df344e4f17369dedd8cf19165c0c5b51dbb21b68475e11 src/admin/file_logs_query.rs 5f68738d1867dfad63324038c1f88addb89801fa925898cbcb15ee2c5b139c67 src/admin/logging_api.rs 781fd5f176dd8f2372f75bd90edcf160708e2d0a8d6a115ba4b283c0cd49eb2d src/admin/mod.rs -7bbb30c7e3d4313cd04fd5b818a13f646d3a65a13b49655867468c31b72acefe src/admin/openapi.json +ad8a581ced4c862541e1042cadc8df8869a3f34d62490b5e11210f9e61c60d99 src/admin/openapi.json 6f68d2545a33bbedc588511dff1179a1634c0c9939fea486adab38b25ee20591 src/admin/operations.rs 257d93a29d0bda96462bcf695aba8d0ec0f9412c379e066ec46ae8ee034e3a53 src/admin/panel_assets.rs f5127855c2994d052678865df36d703b74f4a0afc633daf7718b10da18d26e37 src/admin/panel_content.rs @@ -227,7 +227,7 @@ ea202c67d9acb7614046f153beecdff10d5822b3d5627eaf2ebda33954b36474 src/admin/pref 6930b4f4b45257772b321b20a9becdf9bc4610274852948ba38c2d0cdf02dfaf src/admin/refresh_preferences.rs 409fc0bfa0b35b766e50c63b2e147d439fa31f89f4559df9d7045a903a2da7c0 src/admin/router.rs ec7128da7e6cf67deb99275f5bea38408b95ce6cf97c8d501655c558427f67d1 src/admin/session.rs -69551eebf177add5297ddb3c921022f7861ca706c1b63d3b6fe3b06e4c7a5630 src/admin/status.rs +f4809578efebe1bfc434eea64c4ed23b089a83ef7f843588a2e110d211b09432 src/admin/status.rs bac2116e9a7d5f19a112565e1483787ff6102f489bed0cb3b0b3e2102ddd3edb src/admin/status_live.rs c20f214e2ec2a14d8a88d07a63a27d9396a7a6bf9446f6ee31dbd77b12e4b585 src/admin/status_system.rs ea1d0b8ff69157215f9358f0de35b91462ab2bf1fb97f9ce9b37846d0432c56b src/admin/tail.rs @@ -257,7 +257,7 @@ e799e0406c7ff54cbf71faf704a20265bdf5180a8ed2f26388d0775231365410 src/admin/web/ f6c49948dd32de1e0a03938c4d236c7ad89c7a2b3253b5c6940b214aad799b7b src/admin/web/app/preferences.js 30ec0a7027215eae63946689af2c042de0cf468a6b1054535694da4dd4214cdb src/admin/web/app/rate-sampling.js 3b8e566d81a5b94ef21c73e7805ae128454f085554de9358040de266bcbdb0e0 src/admin/web/app/refresh.js -3db7f720d2ce9dfab9eb5e4241df8ed93d3b44de7d6a85b7c23e4ff452ff8624 src/admin/web/app/runtime.js +09cbbe1d438507c56c32af1bc81abbac430f27d4b58f1ae4ef34b739d1dbb6c6 src/admin/web/app/runtime.js 31201586925e6f4792071d7d03fb05dcc4a69a03c02a4e85eb0746f45af68074 src/admin/web/app/session-resume.js c638e82ebe2c49c61124ab647e74ff594d293fa85131051cff625f9d1f1451a5 src/admin/web/app/settings.js 2281f06990f86acd3ff12fa368e1b73e4c83601e20245f24abbce389dfccb77f src/admin/web/app/sidebar.js @@ -283,11 +283,11 @@ e9cfe14e8e5093e8f8be504d9590643d71935846241f4e73ea4afcafb7f0f806 src/admin/web/ 9efc37b434336db30333f28c09e14355c45332e1d28c64bb6b88f875ba9fd297 src/admin/web/cf_page/placeholder.html 38bb67d9ec6b6e08298d63267afa3a92cbc0818fb0a21fc39520afdca4a995e4 src/admin/web/cf_page/welcome.html 5ad913eb4a06e9da62338da4e6122d4bfef93954b8ee718215d3e00ad1e5ab17 src/admin/web/css/00-tokens.css -9b6aafe8ccac0b198a7a1f02a0fb58f6b68258398bfc869885b0628a800f13ec src/admin/web/css/10-base.css +d7847ed11dbd90ff6a07131bc841c68be104bf50bfef3077894e469f0b408c1b src/admin/web/css/10-base.css 9cd9b62ff8cfba47cb180e29ea5f69b8e97c7817dfcfddcb55fc4e08d11a7184 src/admin/web/css/20-shell.css 99f37617e65ea064e526c161e63587d4081a03be861b6d305f678cf783c4bd1c src/admin/web/css/30-overview.css -178c43087bc8c226e39edb6e06da2ac495831f291f5e59f3cd49a74a87bf340f src/admin/web/css/40-editors.css -fe4621d42adca7649225afe53a0ce67ebf6c24a3b837d19b1f9dadab0b20618b src/admin/web/css/50-settings.css +ffacba6fb5d97e8126f8eeb2d8a8826906c5e91b13250677503be0fa7d268c9b src/admin/web/css/40-editors.css +da6e35a001d80dc4bb772cc7ad5ab16d5a6005e1ee2a9a9e9712a457f1634fff src/admin/web/css/50-settings.css 9bfee7bc5fed42aa5ee17f14d43f73073646fdbc6e7d0466be20ac57740c3bd1 src/admin/web/css/55-policy.css 638171543182172b32e3ac899ff6e63e2bd726983b809d792e88d5b12fe22e34 src/admin/web/css/60-monitoring.css 0fe476fc31c15a9e2bbc3fff1585e78f5c0a04094661d01725bda504ae582da0 src/admin/web/css/70-responsive.css @@ -610,8 +610,8 @@ d9ed71762081732fee3c79192a96a36c744f499e308f74c6d12fd5d7a7679d15 src/tls/certif a71f20dbec5802dffe9d51a78b931062b5abdec2bc82ad6fe98abd9c7b5abd7b src/tls/external_paths.rs 937b95bb8621ab98d7cad3d223e4dee305350fbd0149b7527396d3bdcc28a68b src/tls/external_paths_tests.rs 90ed8c34b49096cf78f50dd014f9e2968942b142ca95d28307f269e3fe5a0fc1 src/tls/server_config.rs -2d46b183ea6ab0ef4827e7ceff4cd87c7fb5a3e987789e222a3a617b5e2bd7db src/tls/tests.rs -90be472a03d0b1962b466afdd82b8935d98f77d2bb17bd437cbfc3a116ffa402 src/tls/types.rs +1afd63bc78e8c585b190deaecd6a5b8d9b3ff920117abf8d299a43bfc3a80b0d src/tls/tests.rs +8a42313bfb9b1a0af238cc5743b1e709d8af130eeb78f03ce6e638cf0bc78133 src/tls/types.rs 58f01b9a6dd1095877cc71445b3ccd651d8b2a1a9c0ad543547840834ec1d91b src/traffic/mod.rs bd62b4ecdcf831d183c7720766a11703c8612d614e3abf38d2bff28df34710fd src/traffic/tests.rs bfbbaa3b949ae946fa929bfbae3fd9a25f2ce792abbd0ed370ccf5683250bc4d src/transform/apply.rs diff --git a/docs/CERTIFICATES.md b/docs/CERTIFICATES.md index 77efcce..eb88a66 100644 --- a/docs/CERTIFICATES.md +++ b/docs/CERTIFICATES.md @@ -40,7 +40,7 @@ HTTP-01 cannot create wildcard certificates; use DNS-01. A staging certificate i Expand a certificate in the Certificates inventory and use **Assign Vhosts** to check/uncheck multiple Vhosts before applying one revisioned Vhost-section save. This updates Vhost certificate mappings, not the PEM files themselves. Verify frontend listener and certificate hostname coverage separately. -The expanded certificate's **Where it is used** lists Vhosts, redirects, 404 hosts, Docker vhosts and the Docker agents that allow the certificate, with hostname coverage and an **Open** link to each editor. Docker vhosts are shown read-only: they take their certificate from the agent's allowed list (**Settings → Docker agents**), so change that list rather than assigning from the certificate. The **Assigned** / **Unassigned** filters and the Assignments tile count Docker vhosts too. A certificate ID can be changed in **Edit** while nothing references it; when a Vhost, redirect, 404 host, Docker agent or the default certificate uses it, the ID is locked and the referencing items are listed. +The expanded certificate's **Where it is used** lists Vhosts, redirects, 404 hosts, Docker vhosts and the Docker agents that allow the certificate, with hostname coverage and an **Open** link to each editor. Docker vhosts are shown read-only: they take their certificate from the agent's allowed list (**Settings → Docker agents**), so change that list rather than assigning from the certificate. A Docker vhost whose agent uses *Automatic* (or whose selected certificates do not cover its names) is listed under the certificate SNI serves for its hostnames and marked **SNI auto**. The **Assigned** / **Unassigned** filters and the Assignments tile count Docker vhosts too. A certificate ID can be changed in **Edit** while nothing references it; when a Vhost, redirect, 404 host, Docker agent or the default certificate uses it, the ID is locked and the referencing items are listed. The reserved HTTP-01 challenge path is available only during eligible issuance/renewal work. It is not a generic public file server and does not bypass authentication for unrelated URLs. diff --git a/langs/en_US.json b/langs/en_US.json index 26a7d98..3e5a1fe 100644 --- a/langs/en_US.json +++ b/langs/en_US.json @@ -4755,7 +4755,7 @@ "certificateSummaryRedirects": "redirects", "certificateSummaryRuntime": "ACME environment", "certificateUntil": "until", - "certificateUsageHelp": "Redirects and 404 hosts are changed in their own editors (Open). Docker vhosts get a certificate from their agent's allowed list (Settings → Docker agents), so they are shown here but cannot be assigned from this view.", + "certificateUsageHelp": "Redirects and 404 hosts are changed in their own editors (Open). Docker vhosts get a certificate from their agent's allowed list (Settings → Docker agents) or, when the agent uses Automatic, by SNI from the hostname (marked SNI auto), so they are shown here but cannot be assigned from this view.", "certificateValidationDns": "DNS-01 (TXT record, wildcards too)", "certificateValidationHttp": "HTTP-01 (port 80 of this server)", "certificateValidityUnknown": "validity unknown", @@ -4802,6 +4802,8 @@ "aclProfileSearch": "Search ACL profiles", "aclProfileSearchPlaceholder": "Name, ID, network, country...", "aclProfileSearchEmpty": "No ACL profiles match this search.", - "aclProfileNotUsed": "Not attached" + "aclProfileNotUsed": "Not attached", + "certificateSniAuto": "SNI auto", + "certificateSniAutoHelp": "The Docker agent has no certificate list (Automatic), so the certificate is chosen by SNI from the requested hostname." } } \ No newline at end of file diff --git a/langs/pl_pl.json b/langs/pl_pl.json index cefa4e1..273f2ff 100644 --- a/langs/pl_pl.json +++ b/langs/pl_pl.json @@ -4755,7 +4755,7 @@ "certificateSummaryRedirects": "przekier.", "certificateSummaryRuntime": "Środowisko ACME", "certificateUntil": "do", - "certificateUsageHelp": "Przekierowania i hosty 404 zmieniasz w ich edytorach (Otwórz). Docker vhosty dostają certyfikat z listy dopuszczonej w agencie (Ustawienia → Agenci Dockera), więc są tu widoczne, ale nie da się ich przypisać z tego widoku.", + "certificateUsageHelp": "Przekierowania i hosty 404 zmieniasz w ich edytorach (Otwórz). Docker vhosty dostają certyfikat z listy dopuszczonej w agencie (Ustawienia → Agenci Dockera) albo — gdy agent ma tryb Automatycznie — przez SNI z nazwy hosta (oznaczenie SNI auto), więc są tu widoczne, ale nie da się ich przypisać z tego widoku.", "certificateValidationDns": "DNS-01 (rekord TXT, także wildcard)", "certificateValidationHttp": "HTTP-01 (port 80 tego serwera)", "certificateValidityUnknown": "ważność nieznana", @@ -4802,6 +4802,8 @@ "aclProfileSearch": "Szukaj profili ACL", "aclProfileSearchPlaceholder": "Nazwa, ID, sieć, kraj...", "aclProfileSearchEmpty": "Żaden profil ACL nie pasuje do wyszukiwania.", - "aclProfileNotUsed": "Nieprzypisany" + "aclProfileNotUsed": "Nieprzypisany", + "certificateSniAuto": "SNI auto", + "certificateSniAutoHelp": "Agent Docker nie ma listy certyfikatów (Automatycznie), więc certyfikat jest wybierany przez SNI na podstawie nazwy hosta." } } \ No newline at end of file diff --git a/src/admin/openapi.json b/src/admin/openapi.json index e336ff9..e4a55f4 100644 --- a/src/admin/openapi.json +++ b/src/admin/openapi.json @@ -4124,6 +4124,13 @@ "certificate_mismatch": { "type": "boolean", "description": "True when the certificate was used although it does not cover the hostnames (the assignment allows a mismatch)." + }, + "sni_certificate_ids": { + "type": "array", + "items": { + "type": "string" + }, + "description": "When no certificate is selected for the route (agent in Automatic mode or no selected certificate covers the hostnames), the stored certificates SNI serves for its hostnames." } }, "required": [ diff --git a/src/admin/status.rs b/src/admin/status.rs index 1877ced..a6b3ae5 100644 --- a/src/admin/status.rs +++ b/src/admin/status.rs @@ -260,11 +260,47 @@ async fn backend_status(State(state): State>) -> Json { "active_frontends":state.active_listeners, "desired_frontends":snapshot.listeners}), ) } +fn sni_certificates( + selected: Option<&str>, + hosts: &[String], + certificates: &[crate::tls::Certificate], +) -> Vec { + if selected.is_some() { + return Vec::new(); + } + let mut ids = Vec::new(); + for host in hosts { + if let Some(id) = crate::tls::sni_certificate_id(certificates, host) { + if !ids.contains(&id) { + ids.push(id); + } + } + } + ids +} fn docker_runtime_views(state: &Arc) -> (Vec, Vec, Value) { let snapshot = state.config.load_full(); let config = &snapshot.envelope.config; let observed = state.docker.latest(); let (publications, issues) = crate::docker::label_publications(config, &observed); + let sni_pool: Vec = config + .tls + .certificates + .iter() + .cloned() + .map(|mut certificate| { + if certificate.covered_hosts.is_empty() { + if let Some(directory) = state.policy.cert_dir.as_deref() { + if let Ok(names) = + crate::tls::certificate_covered_hosts(directory, &certificate.cert_file) + { + certificate.covered_hosts = names; + } + } + } + certificate + }) + .collect(); let mut routes = Vec::new(); let mut ids = std::collections::HashSet::new(); for agent in &config.docker_agents.agents { @@ -282,7 +318,8 @@ fn docker_runtime_views(state: &Arc) -> (Vec, Vec, Value) { &config.tls.certificates, &hosts, ); - routes.push(json!({"agent_id": &agent.id, "service_key": &assignment.service_key, "pool_id": pool_id, "enabled": assignment.enabled, "hosts": hosts, "certificate_id": certificate_id, "certificate_mismatch": certificate_mismatch})); + let sni_certificate_ids = sni_certificates(certificate_id.as_deref(), &hosts, &sni_pool); + routes.push(json!({"agent_id": &agent.id, "service_key": &assignment.service_key, "pool_id": pool_id, "enabled": assignment.enabled, "hosts": hosts, "certificate_id": certificate_id, "certificate_mismatch": certificate_mismatch, "sni_certificate_ids": sni_certificate_ids})); } } for publication in &publications { @@ -303,7 +340,8 @@ fn docker_runtime_views(state: &Arc) -> (Vec, Vec, Value) { ) }) .unwrap_or((None, false)); - routes.push(json!({"agent_id": &publication.agent_id, "service_key": &publication.assignment.service_key, "pool_id": pool_id, "source": "labels", "assignment": &publication.assignment, "hosts": &publication.hosts, "certificate_id": certificate_id, "certificate_mismatch": certificate_mismatch})); + let sni_certificate_ids = sni_certificates(certificate_id.as_deref(), &publication.hosts, &sni_pool); + routes.push(json!({"agent_id": &publication.agent_id, "service_key": &publication.assignment.service_key, "pool_id": pool_id, "source": "labels", "assignment": &publication.assignment, "hosts": &publication.hosts, "certificate_id": certificate_id, "certificate_mismatch": certificate_mismatch, "sni_certificate_ids": sni_certificate_ids})); } let pools = snapshot .pools diff --git a/src/admin/web/app/runtime.js b/src/admin/web/app/runtime.js index df2794d..7c9cdc8 100644 --- a/src/admin/web/app/runtime.js +++ b/src/admin/web/app/runtime.js @@ -70,14 +70,14 @@ function certificateUsage(cert) { vhosts: (config.vhosts || []).filter(item => item.certificate_id === cert.id).map(item => ({ id: item.id, hosts: hostsOf(item), mismatch: item.allow_certificate_mismatch === true, open: () => { setPanel("vhosts"); window.rustProxyVhosts?.edit(item.id); } })), redirects: (config.redirects || []).filter(item => item.certificate_id === cert.id).map(item => ({ id: item.id, hosts: hostsOf(item), open: () => { setPanel("redirects"); window.rustProxyRedirects?.edit(item.id); } })), notfound: (config.not_found_hosts || []).filter(item => item.certificate_id === cert.id).map(item => ({ id: item.id, hosts: hostsOf(item), open: () => { setPanel("notfound"); window.rustProxyNotFound?.edit(item.id); } })), - dockerVhosts: certificateDockerRoutes().filter(route => route.certificate_id === cert.id).map(route => ({ id: `${route.agent_id} · ${route.service_key}`, hosts: route.hosts || [], mismatch: route.certificate_mismatch === true, docker: true, open: () => { setPanel("docker-vhosts"); const search = $("docker-search"); if (search) { search.value = (route.hosts || [])[0] || route.service_key; search.dispatchEvent(new Event("input", { bubbles: true })); } } })), + dockerVhosts: certificateDockerRoutes().filter(route => route.certificate_id === cert.id || (route.sni_certificate_ids || []).includes(cert.id)).map(route => ({ id: `${route.agent_id} · ${route.service_key}`, hosts: route.hosts || [], mismatch: route.certificate_mismatch === true, sni: route.certificate_id !== cert.id, docker: true, open: () => { setPanel("docker-vhosts"); const search = $("docker-search"); if (search) { search.value = (route.hosts || [])[0] || route.service_key; search.dispatchEvent(new Event("input", { bubbles: true })); } } })), docker: (config.docker_agents?.agents || []).filter(agent => [agent.certificate_id, ...(agent.certificate_ids || [])].includes(cert.id)).map(agent => ({ id: agent.id, hosts: agent.domains || [], open: () => { setPanel("settings"); window.rustProxySettings?.select?.("docker-agents"); } })) }; const legacy = []; for (const item of config.vhosts || []) if (item.certificate_id === cert.id) legacy.push(`vhost:${item.id}`); for (const item of config.redirects || []) if (item.certificate_id === cert.id) legacy.push(`redirect:${item.id}`); for (const item of config.not_found_hosts || []) if (item.certificate_id === cert.id) legacy.push(`404:${item.id}`); - for (const route of certificateDockerRoutes()) if (route.certificate_id === cert.id) legacy.push(`docker:${route.agent_id}/${route.service_key}`); + for (const route of certificateDockerRoutes()) if (route.certificate_id === cert.id || (route.sni_certificate_ids || []).includes(cert.id)) legacy.push(`docker:${route.agent_id}/${route.service_key}`); const admin = config.administration?.certificate_id === cert.id, isDefault = settings.default_certificate === cert.id; if (admin) legacy.push(t("administration")); if (isDefault) legacy.push(t("defaultLabel")); @@ -224,7 +224,8 @@ function renderCertificates() { const cover = certificateCoverageState(coverage, item.hosts); const pillText = cover.state === "full" ? t("certificateCovered") : cover.state === "unknown" ? t("certificateCoverageUnknownShort") : `${t("certificateNotCovered")}: ${cover.missing.join(", ")}${item.mismatch ? ` · ${t("certificateMismatchAccepted")}` : ""}`; const open = el("button", t("certificateOpen"), "quiet certificate-usage-open"); open.type = "button"; open.dataset.uiIconName = "none"; open.addEventListener("click", item.open); - row.append(el("span", item.id, "mono"), el("span", item.hosts.join(", ") || "-", "fine"), el("span", pillText, `pill${cover.state === "full" ? " live" : cover.state === "unknown" ? "" : " warn"}`), open); + const idCell = el("span", item.id, "mono"); if (item.sni) { const sni = el("span", t("certificateSniAuto"), "pill certificate-usage-sni"); sni.title = t("certificateSniAutoHelp"); idCell.append(" ", sni); } + row.append(idCell, el("span", item.hosts.join(", ") || "-", "fine"), el("span", pillText, `pill${cover.state === "full" ? " live" : cover.state === "unknown" ? "" : " warn"}`), open); group.append(row); } usageSection.append(group); diff --git a/src/admin/web/css/10-base.css b/src/admin/web/css/10-base.css index 3176a3a..e35cf33 100644 --- a/src/admin/web/css/10-base.css +++ b/src/admin/web/css/10-base.css @@ -73,6 +73,10 @@ textarea { min-height: var(--ui-field-min-height); } +select { + line-height: 1.5; +} + a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; diff --git a/src/admin/web/css/40-editors.css b/src/admin/web/css/40-editors.css index 6ac5a75..faedd19 100644 --- a/src/admin/web/css/40-editors.css +++ b/src/admin/web/css/40-editors.css @@ -109,6 +109,10 @@ align-self: end; } +:is(.vh-grid, .field-grid)>:is(.vh-field, label:not([class]), .auto-id-field)>:is(input:not([type=checkbox], [type=radio]), select) { + align-self: start; +} + :is(.vh-grid, .field-grid):has(>.auto-id-field:not(.is-compact))>:is(.vh-field, label:not([class]), .auto-id-field) { grid-template-rows: none; } @@ -1349,6 +1353,27 @@ p, margin-bottom: 4px; } +.acl-profile-rule label>span.acl-profile-rule-action-badge { + display: flex; + margin-bottom: 0; + font-size: 11px; +} + +.acl-profile-rule :is(select, input, .acl-profile-rule-action-badge, .acl-profile-rule-remove) { + box-sizing: border-box; + height: 32px; + min-height: 32px; + margin-block: 0; +} + +.acl-profile-rule .acl-profile-rule-action-badge { + padding-block: 0; +} + +.acl-profile-rule>label { + margin-bottom: 0; +} + .acl-profile-bulk { margin-top: 9px; border-top: 1px solid var(--line); diff --git a/src/admin/web/css/50-settings.css b/src/admin/web/css/50-settings.css index 510890c..de90a53 100644 --- a/src/admin/web/css/50-settings.css +++ b/src/admin/web/css/50-settings.css @@ -671,7 +671,7 @@ html:not([data-switch-controls="false"]) .docker-publish-field input.docker-publ .docker-agent-grid select { width: 100%; min-width: 0; - min-height: 38px; + min-height: var(--ui-field-min-height); margin: 0; box-sizing: border-box; } @@ -1423,7 +1423,7 @@ html[data-dashboard-density=normal] #panel-overview .stat>span, .docker-certificate-field>select { width: 100%; - min-height: 38px; + min-height: var(--ui-field-min-height); box-sizing: border-box; } diff --git a/src/tls/tests.rs b/src/tls/tests.rs index e95dc76..86b629b 100644 --- a/src/tls/tests.rs +++ b/src/tls/tests.rs @@ -1,6 +1,28 @@ mod tests { use super::*; + #[test] + fn sni_certificate_id_prefers_bound_names_then_the_narrowest_covering_certificate() { + let cert = |id: &str, hosts: &[&str], covered: &[&str]| Certificate { + issuer: None, + id: id.into(), + covered_hosts: covered.iter().map(|v| v.to_string()).collect(), + hosts: hosts.iter().map(|v| v.to_string()).collect(), + cert_file: format!("{id}.pem"), + key_file: format!("{id}.key"), + }; + let certificates = vec![ + cert("wide", &[], &["*.apps.example.org", "apps.example.org", "*.example.org", "example.org"]), + cert("apps", &[], &["*.apps.example.org", "apps.example.org"]), + cert("bound", &["shop.apps.example.org"], &[]), + ]; + assert_eq!(sni_certificate_id(&certificates, "web.apps.example.org").as_deref(), Some("apps")); + assert_eq!(sni_certificate_id(&certificates, "SHOP.apps.example.org.").as_deref(), Some("bound")); + assert_eq!(sni_certificate_id(&certificates, "www.example.org").as_deref(), Some("wide")); + assert_eq!(sni_certificate_id(&certificates, "a.b.apps.example.org"), None); + assert_eq!(sni_certificate_id(&certificates, "example.net"), None); + } + fn private_tempdir() -> tempfile::TempDir { let dir = tempfile::tempdir().unwrap(); #[cfg(unix)] diff --git a/src/tls/types.rs b/src/tls/types.rs index a4a1eea..0d18e3e 100644 --- a/src/tls/types.rs +++ b/src/tls/types.rs @@ -278,6 +278,35 @@ fn lookup(map: &HashMap>, host: &str) -> Option Option { + let host = normalize_host(server_name).ok()?; + let candidates = |exact: bool| { + let mut best: Option<(usize, &str)> = None; + for certificate in certificates { + let mut names: Vec = certificate + .hosts + .iter() + .chain(if exact { [].iter() } else { certificate.covered_hosts.iter() }) + .filter_map(|name| normalize_host_pattern(name).ok()) + .collect(); + names.sort(); + names.dedup(); + let wildcard = single_label_wildcard(&host); + if !names + .iter() + .any(|name| *name == host || Some(name) == wildcard.as_ref()) + { + continue; + } + let size = if exact { 0 } else { names.len() }; + if best.is_none_or(|(current, _)| size < current) { + best = Some((size, certificate.id.as_str())); + } + } + best.map(|(_, id)| id.to_owned()) + }; + candidates(true).or_else(|| candidates(false)) +} impl Resolver { fn named(&self, server_name: &str) -> Option> { let host = normalize_host(server_name).ok()?;