Skip to content

fix: remove --gateway-insecure by adding route FQDN to cert SAN and automating CA trust - #42

Draft
LinoyBitan1 wants to merge 2 commits into
validatedpatterns-sandbox:mainfrom
LinoyBitan1:fix/remove-gateway-insecure
Draft

fix: remove --gateway-insecure by adding route FQDN to cert SAN and automating CA trust#42
LinoyBitan1 wants to merge 2 commits into
validatedpatterns-sandbox:mainfrom
LinoyBitan1:fix/remove-gateway-insecure

Conversation

@LinoyBitan1

@LinoyBitan1 LinoyBitan1 commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fix gateway TLS verification end-to-end by adding the external route FQDN to the gateway certificate SANs and automating CA certificate distribution to the CLI.

Stop requiring --gateway-insecure by putting the route FQDN on the gateway cert SAN and copying the CA to the CLI.
The cert was issued only for host.openshell.internal, so the CLI rejected the OpenShift route hostname. Cloud-init
writes a systemd drop-in with --server-san ; the setup Job daemon-reloads and restarts the gateway so that drop-in is used. The Job then puts the VM CA in Secret -gateway-ca. make openshell-saw-configure-gateway copies it to ~/.config/openshell/gateways//mtls/ca.crt before registering the gateway, and fails if the Secret is missing.

--gateway-insecure is removed from Makefile targets, README, and helper scripts.

Jira: APPENG-5921

Background

The openshell CLI already supports trusting a custom CA at ~/.config/openshell/gateways/<name>/mtls/ca.crt, but two things prevented it from working:

  1. SAN mismatch — the gateway generated its TLS certificate with --server-san host.openshell.internal, but the external route hostname (e.g. openshell-saw-gateway-openshell-agents.apps.<cluster>) was not included. The CLI rejected the certificate with certificate not valid for name.
  2. No CA distribution — the gateway's CA stayed on the VM and was never copied to the client, so the CLI could not verify the server certificate even if the SANs matched.

As a result, every CLI invocation required --gateway-insecure.

Changes

  • _helpers.tplopenshell-sandbox.routeHost computes the external route FQDN from route.host or global.clusterDomain.
  • cloudinit-sandbox.yaml — writes OPENSHELL_ROUTE_FQDN into gateway.env and a user systemd drop-in (route-san.conf) that adds the route FQDN as an extra --server-san.
  • upgrade-openshell.shdaemon-reload && restart of the user gateway unit so the drop-in is picked up after the binary upgrade (first-boot setup may already have loaded the unit before the drop-in existed).
  • export-ca-cert.sh — new setup Job phase: SSH the CA off the VM into Secret <name>-gateway-ca; return 1 if the file is missing so the Job retries instead of succeeding with no Secret.
  • run-setup.sh — sources export-ca-cert.sh after the OpenShell upgrade.
  • openshell-saw-create.sh — sets route.host from the cluster ingress domain so the quickstart path always has a FQDN.
  • Makefile-quickstart — removed --gateway-insecure. configure-gateway copies the CA from the Secret into mtls/ca.crt, fails if it is missing, then gateway add / select.
  • README.md — removed --gateway-insecure from examples.
  • demo-governance.sh, governance-profile.sh, openshell-saw-gui.sh — removed --gateway-insecure and grep -v 'TLS certificate' pipes.

Verification

  • Gateway certificate includes the external route FQDN in its SANs
  • make openshell-saw-configure-gateway copies the CA certificate to the CLI config
  • openshell sandbox list works without --gateway-insecure
  • No TLS warnings appear in CLI output
  • --gateway-insecure is fully removed from Makefile targets and README

…utomating CA trust

The gateway generated TLS certs with only host.openshell.internal as a
SAN, so the CLI rejected the cert when connecting via the external route
hostname. This required --gateway-insecure everywhere.

Fix:
- Add routeHost helper that resolves from route.host or global.clusterDomain
- Cloud-init writes OPENSHELL_ROUTE_FQDN to gateway.env and creates a
  systemd override adding the route FQDN as an additional --server-san
- openshell-saw-create.sh computes the route hostname from the cluster's
  ingress domain and passes it to Helm via --set route.host
- New export-ca-cert.sh setup Job phase extracts the CA cert from the VM
  and stores it in a Kubernetes Secret (<name>-gateway-ca)
- configure-gateway target reads the CA cert from the Secret and places
  it at ~/.config/openshell/gateways/<name>/mtls/ca.crt
- Remove --gateway-insecure from all Makefile targets, scripts, and README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant