Skip to content

network: keep every trusted openconnect pin for multi-node gateways - #4201

Merged
bbedward merged 1 commit into
duxlabs-dev:masterfrom
martinvalentine:fix/openconnect-multi-node-pins
Nov 8, 2026
Merged

bbedward merged 1 commit into
duxlabs-dev:masterfrom
martinvalentine:fix/openconnect-multi-node-pins

Conversation

@martinvalentine

Copy link
Copy Markdown
Contributor

Description

Fortinet password profiles (openconnect, authtype=password) keep asking the user to trust the server certificate on every connect when the gateway is a FortiGate HA cluster.

Why it happens. An HA pair behind one address answers each TLS connection from either node, and each node presents its own factory certificate (CN=<serial>, issued by fortinet-subca2001, so it never matches the hostname and has to be pinned). Against our gateway, 20 handshakes split 11/9 between the two nodes with no fixed order. handleOpenConnectPasswordAuth stores a single pin in certificate:<gateway>, and trusting a new certificate overwrites it. Trusting node B forgets node A, so the next connection that lands on A shows "The server certificate has changed" again, and so on.

What this changes.

  • certificate:<gateway> now holds a comma-separated list of pins. Trusting a certificate appends to the list instead of replacing it, so each node is confirmed once. This is the same approach appendTrustedCert already takes for the Fortinet SAML path (trusted-cert, openfortivpn digests).
  • runOpenConnectPasswordAuth passes every trusted pin as its own --servercert= flag. openconnect accepts repeated flags and matches any of them. A single comma-joined value is treated as one pin.
  • Pin matching is case sensitive, because pins are base64. That is why it does not reuse certDigestTrusted, which uses EqualFold for hex digests.
  • A stored single pin reads as a one-element list, so existing profiles keep working without migration. There are no UI or protocol changes, and the existing server-certificate / server-certificate-changed prompt reasons are kept.
  • gwcert handed to NetworkManager is still the single pin of the node that answered the authentication.

Known limitation, outside dux-shell. The tunnel itself is started by nm-openconnect-service, which passes only one --servercert (the gwcert secret). When the tunnel connection lands on the other HA node, it can still fail with None of the 1 fingerprint(s) specified via --servercert match. This is tracked upstream in NetworkManager-openconnect#152, which proposes a ;-separated gwcert list, and #149. Sending a list in gwcert today would break the stock plugin, so this PR deliberately leaves it alone. Once #152 lands, I plan to follow up with a PR that passes the full list.

I use this path daily against a FortiGate HA pair, so I'm happy to keep looking after the openconnect/Fortinet password flow, including that follow-up, and to help triage related reports.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Refactor / internal cleanup
  • Documentation
  • Other

Related issues

No existing issue in this repo. Related upstream: GNOME/NetworkManager-openconnect#152, GNOME/NetworkManager-openconnect#149.

Screenshots / video

No visual change. The existing "Untrusted VPN certificate" prompt now appears once per node instead of on every connect.

Checklist

  • My code follows the conventions in CONTRIBUTING.md
  • I have tested my changes locally
  • New user-facing strings are wrapped in I18n.tr() with translator context, reusing existing terms where possible (no new strings)
  • Go changes: ran make fmt, added/updated tests, make test passes, and go mod tidy is clean
  • QML changes: ran make lint-qml with no new warnings (no QML changes)
  • I have opened a corresponding pull request in dux-docs to document any new behaviors: https://github.com/duxlabs-dev/dux-docs (no documented behavior changes)

Tests: TestOpenConnectCertificateRotationReprompts now expects the old pin to be kept alongside the new one. TestOpenConnectTrustedPinsForEveryNode checks that with both pins trusted, the node that answers is accepted without a prompt and openconnect receives both --servercert flags. TestAppendServerCertPin covers dedupe, blank entries and case sensitivity. Both behavior tests fail on current master. go vet ./... reports 7 errors in generated mocks (MarshalJSON signatures), which also occur on master and are untouched here.

@github-actions github-actions Bot added core Go daemon and CLI under core/ fix labels Nov 8, 2026
@bbedward

bbedward commented Nov 8, 2026

Copy link
Copy Markdown
Member

/claude review

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Claude review

No issues found.
Checked: pin list parsing/dedupe, repeated --servercert args, the untrusted-cert prompt and retry path in handleOpenConnectPasswordAuth, persisting the merged list in certificate:<gateway>, the gwcert fallback for a stored single pin, the Fingerprint fallback that only applies when there is one pin, and the new and updated tests. Model: claude-opus-5-5.

@bbedward
bbedward merged commit a15a10b into duxlabs-dev:master Nov 8, 2026
6 checks passed
dux-ci Bot pushed a commit that referenced this pull request Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Go daemon and CLI under core/ fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants