Skip to content

Commit 1a64166

Browse files
committed
cli/serve: add interactive flow for enabling HTTPS certs
When trying to use serve with https, send users through https cert provisioning enablement before editing the ServeConfig. Updates tailscale/corp#10577 Signed-off-by: Sonia Appasamy <sonia@tailscale.com>
1 parent 0052830 commit 1a64166

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

cmd/tailscale/cli/serve.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"strings"
2424

2525
"github.com/peterbourgon/ff/v3/ffcli"
26+
"golang.org/x/exp/slices"
2627
"tailscale.com/client/tailscale"
2728
"tailscale.com/ipn"
2829
"tailscale.com/ipn/ipnstate"
@@ -233,6 +234,21 @@ func (e *serveEnv) runServe(ctx context.Context, args []string) error {
233234
return flag.ErrHelp
234235
}
235236

237+
if srcType == "https" && !turnOff {
238+
// Running serve with https requires that the tailnet has enabled
239+
// https cert provisioning. Send users through an interactive flow
240+
// to enable this if not already done.
241+
//
242+
// TODO(sonia,tailscale/corp#10577): The interactive feature flow
243+
// is behind a control flag. If the tailnet doesn't have the flag
244+
// on, enableFeatureInteractive will error. For now, we hide that
245+
// error and maintain the previous behavior (prior to 2023-08-15)
246+
// of letting them edit the serve config before enabling certs.
247+
e.enableFeatureInteractive(ctx, "serve", func(caps []string) bool {
248+
return slices.Contains(caps, tailcfg.CapabilityHTTPS)
249+
})
250+
}
251+
236252
srcPort, err := parseServePort(srcPortStr)
237253
if err != nil {
238254
return fmt.Errorf("invalid port %q: %w", srcPortStr, err)

0 commit comments

Comments
 (0)