feat(tunnel): enhance TLS configuration with custom certificate and Let's Encrypt support
gosunuts committed
Feb 24, 2026 at 17:36 UTC
4ee046d6faed47a0ad6c6d64049002518e35ebce
1 file changed
+9
-1
cmd/portal-tunnel/main.go
+9
-1
@@ -121,9 +121,17 @@ func runServiceTunnel(ctx context.Context, relayURLs []string, cfg Config, origi
121
if cfg.TLSDomain == "" {
122
return fmt.Errorf("TLS enabled but domain not specified")
123
}
124
- clientOpts = append(clientOpts, sdk.WithTLS(cfg.TLSDomain))
124
+
125
if cfg.TLSCert != "" && cfg.TLSKey != "" {
126
+ // Use custom certificate
127
clientOpts = append(clientOpts, sdk.WithTLSCert(cfg.TLSCert, cfg.TLSKey))
128
+ log.Info().Str("service", cfg.Name).Msg("TLS: Using custom certificate")
129
+ } else if cfg.TLSAutocert {
130
+ // Use Let's Encrypt autocert
131
+ clientOpts = append(clientOpts, sdk.WithTLS(cfg.TLSDomain))
132
+ log.Info().Str("service", cfg.Name).Str("domain", cfg.TLSDomain).Msg("TLS: Using Let's Encrypt autocert")
133
+ } else {
134
+ return fmt.Errorf("TLS enabled but no certificate source configured (set --tls-autocert or provide --tls-cert and --tls-key)")
135
}
136
}
137