diff --git a/internal/app/archied/control_plane.go b/internal/app/archied/control_plane.go index 0a63bb03a..dbe26ba22 100644 --- a/internal/app/archied/control_plane.go +++ b/internal/app/archied/control_plane.go @@ -446,11 +446,15 @@ func (b *boot) refuseRuntimeChange(ctx context.Context) error { // egress hosts are read per task. type openShellBoot struct { address, workspace, servicesHost string + caFile, certFile, keyFile string token config.SecretRef } func bootOnlyOpenShell(c config.OpenShellConfig) openShellBoot { - return openShellBoot{address: c.Address, workspace: c.Workspace, servicesHost: c.ServicesHost, token: c.Token} + return openShellBoot{ + address: c.Address, workspace: c.Workspace, servicesHost: c.ServicesHost, + caFile: c.CAFile, certFile: c.CertFile, keyFile: c.KeyFile, token: c.Token, + } } // runtimeName is runtime with the empty default spelled out. diff --git a/internal/app/archied/openshell.go b/internal/app/archied/openshell.go index f8cf3d5b3..65c7464c8 100644 --- a/internal/app/archied/openshell.go +++ b/internal/app/archied/openshell.go @@ -31,7 +31,11 @@ func startOpenShell(ctx context.Context, cfgHolder *config.Holder, secrets *secr } auth = v1.StaticToken(token) } - client, err := v1.NewClient(v1.Config{Address: settings.Address, Auth: auth}) + var tls *v1.TLSConfig + if settings.CAFile != "" || settings.CertFile != "" || settings.KeyFile != "" { + tls = &v1.TLSConfig{CAFile: settings.CAFile, CertFile: settings.CertFile, KeyFile: settings.KeyFile} + } + client, err := v1.NewClient(v1.Config{Address: settings.Address, Auth: auth, TLS: tls}) if err != nil { return nil, nil, nil, fmt.Errorf("openshell gateway %s: %w", settings.Address, err) } diff --git a/internal/config/config.go b/internal/config/config.go index bfe2793f1..aff510b09 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -712,6 +712,13 @@ type OpenShellConfig struct { // Token resolves to the gateway's bearer token. Zero sends none, which // only a gateway allowing unauthenticated users accepts. Token SecretRef `toml:"token" yaml:"token" json:"token"` + // CAFile, CertFile and KeyFile are PEM files for a gateway that requires + // mutual TLS: the CA its server certificate is checked against, and the + // client certificate and key archie presents. Empty uses no client + // certificate. + CAFile string `toml:"ca_file" yaml:"ca_file" json:"ca_file"` + CertFile string `toml:"cert_file" yaml:"cert_file" json:"cert_file"` + KeyFile string `toml:"key_file" yaml:"key_file" json:"key_file"` // ServicesHost is the DNS name sandboxes reach this host's NATS and State // Store by when those are addressed by IP or loopback: sandbox policy // admits TCP only to DNS names, and never to loopback. diff --git a/internal/infrastructure/controlplanestore/container_settings.go b/internal/infrastructure/controlplanestore/container_settings.go index 74ce70286..54c603676 100644 --- a/internal/infrastructure/controlplanestore/container_settings.go +++ b/internal/infrastructure/controlplanestore/container_settings.go @@ -133,6 +133,9 @@ func validateRuntime(settings config.ContainerConfig) error { default: return fmt.Errorf("runtime must be docker or openshell") } + if (settings.OpenShell.CertFile == "") != (settings.OpenShell.KeyFile == "") { + return fmt.Errorf("the openshell client certificate and key go together") + } if (settings.OpenShell.Token.Engine == "") != (settings.OpenShell.Token.Key == "") { return fmt.Errorf("the openshell token reference needs both an engine and a key") } diff --git a/ui/src/settings/ContainerRuntimePage.vue b/ui/src/settings/ContainerRuntimePage.vue index 9360d911f..2ed46b01a 100644 --- a/ui/src/settings/ContainerRuntimePage.vue +++ b/ui/src/settings/ContainerRuntimePage.vue @@ -51,6 +51,9 @@ interface ContainerRuntime { address: string; workspace: string; token: { engine: string; key: string }; + ca_file: string; + cert_file: string; + key_file: string; services_host: string; egress_hosts: string[]; }; @@ -176,6 +179,54 @@ function formatHours(seconds: number): string { +