client: Present a client certificate on TLS dials when configured

This relates to gitlab#634060, which it does not close, and is part of gitlab#634072.

The Gitaly client can now present a client certificate on tls:// and dns+tls:// connections. client.WithClientCertificate is exported so Workhorse and gitlab-shell, which dial through the public package, can use it later. The internal client also gets a loader for the GITALY_TLS_CLIENT_CERT_FILE and GITALY_TLS_CLIENT_KEY_FILE pair. Nothing calls either yet, so merging this changes no behavior.

Merge order: second of four. It depends on !9554 (merged) and comes before the Gitaly and Praefect outbound MRs, which use it. It targets A's branch, zt/mtls-a-listener, so its diff shows only its own 3 commits. There is no diagram because it adds one option and one loader and no new path.

Claims and not in this MR

Code citations are at 23712dbf. Servers are verified against the system pool before the certificate is sent.

  • The option and the TLS config that carries it: internal/grpc/client/dial.go:144-148,151-161, wrapped publicly at client/dial.go:112. The certificate is read only in the secure branch, so unix: and plaintext dials are unchanged (dial.go:230-242), and it is ignored with WithTransportCredentials. Tests: TestWithClientCertificate in client/dial_test.go:968 and internal/grpc/client/dial_test.go:508.
  • The loader returns nothing when neither variable is set, and an error naming the missing variable when only one is: internal/grpc/client/client_certificate.go:25. Test: TestCertificateFromEnvironment. All 3 commits build and pass go vet, and none is flagged by the commit linter. On a private copy of this branch every job that runs by default passed. The manual jobs were not run.
  • Not here: any caller (Gitaly's and Praefect's are the next two MRs), a client-side CA variable, and the Workhorse and gitlab-shell changes.

An AI coding assistant wrote this change and ran the checks above on test VMs.

Merge request reports

Loading
Loading