Comparison

core/portmanager.lua @ 11535:180c5951e7e4

core.portmanager: Allow overriding expected SNI name per service E.g. VirtualHost"example.com" https_name = "xmpp.example.com"
author Kim Alvefur <zash@zash.se>
date Wed, 05 May 2021 17:52:51 +0200
parent 11412:77785c5d6773
child 11536:fb9bd9fa4356
comparison
equal deleted inserted replaced
11534:1cef62ca3e03 11535:180c5951e7e4
235 in active_services:iter(service, nil, nil, nil) do 235 in active_services:iter(service, nil, nil, nil) do
236 if active_service.server.hosts and active_service.tls_cfg then 236 if active_service.server.hosts and active_service.tls_cfg then
237 local config_prefix = (active_service.config_prefix or name).."_"; 237 local config_prefix = (active_service.config_prefix or name).."_";
238 if config_prefix == "_" then config_prefix = ""; end 238 if config_prefix == "_" then config_prefix = ""; end
239 local prefix_ssl_config = config.get(host, config_prefix.."ssl"); 239 local prefix_ssl_config = config.get(host, config_prefix.."ssl");
240 local autocert = certmanager.find_host_cert(host); 240 local alternate_host = service and config.get(host, service.."_host");
241 local autocert = certmanager.find_host_cert(alternate_host or host);
241 -- luacheck: ignore 211/cfg 242 -- luacheck: ignore 211/cfg
242 local ssl, err, cfg = certmanager.create_context(host, "server", prefix_ssl_config, autocert, active_service.tls_cfg); 243 local ssl, err, cfg = certmanager.create_context(host, "server", prefix_ssl_config, autocert, active_service.tls_cfg);
243 if ssl then 244 if ssl then
244 active_service.server.hosts[host] = ssl; 245 active_service.server.hosts[alternate_host or host] = ssl;
245 else 246 else
246 log("error", "Error creating TLS context for SNI host %s: %s", host, err); 247 log("error", "Error creating TLS context for SNI host %s: %s", host, err);
247 end 248 end
248 end 249 end
249 end 250 end