Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions api/types/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package types

import (
"sort"
"strings"

"github.com/gravitational/trace"

Expand Down Expand Up @@ -167,6 +168,13 @@ func (d *WindowsDesktopV3) CheckAndSetDefaults() error {
return trace.BadParameter("WindowsDesktopV3.Spec missing Addr field")
}

// We use SNI to identify the desktop to route a connection to,
// and '.' will add an extra subdomain, preventing Teleport from
// correctly establishing TLS connections.
if name := d.GetName(); strings.Contains(name, ".") {
return trace.BadParameter("invalid name %q: desktop names cannot contain periods", name)
}

d.setStaticFields()
if err := d.ResourceHeader.CheckAndSetDefaults(); err != nil {
return trace.Wrap(err)
Expand Down
6 changes: 6 additions & 0 deletions api/types/desktop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,9 @@ func TestWindowsDesktopsSorter(t *testing.T) {
desktops := makeDesktops(testValsUnordered, "does-not-matter")
require.True(t, trace.IsNotImplemented(WindowsDesktops(desktops).SortByCustom(sortBy)))
}

func TestInvalidDesktopName(t *testing.T) {
_, err := NewWindowsDesktopV3("name-contains.period", nil,
WindowsDesktopSpecV3{Addr: "desktop.example.com:3389"})
require.True(t, trace.IsBadParameter(err), "want bad parameter error, got %v", err)
}