Present a TLS client certificate to Gitaly

What does this MR do and why?

Rails cannot present a client certificate to a Gitaly TLS listener, one gap in #634072. This adds gitaly.client_certificate_file and gitaly.client_private_key_file to gitlab.yml. Presented on tls:// and dns+tls:// addresses only; unset means unchanged.

Depends on gitaly!9554 (merged), which verifies client certificates.

  • One pair serves every storage.
  • Under verify_if_given, the pair must chain to Gitaly's client CA.
  • gitaly-backup gets the pair through environment variables, which it reads once gitaly!9556 merges.
  • Workhorse and GitLab Shell present no certificate yet, so require also waits on #634060 and the client option in gitaly!9555 (merged).
  • The names follow gitlab.yml's certificate_file and private_key_file, not the issue's client_cert_path. gitlab:gitaly:check does not report the certificate.

Boot and connection path

sequenceDiagram
    participant Op as gitlab.yml
    participant Boot as Rails at boot
    participant Rails as Rails requests
    participant Backup as gitaly-backup
    participant Gitaly as Gitaly TLS listener
    Boot->>Op: resolve both settings
    Boot->>Boot: read and parse certificate and key
    Note over Boot: any failure stops startup<br/>and names the setting
    Note over Rails: reuses the pair read at boot
    Rails->>Gitaly: tls:// address, CA bundle plus key and chain
    Rails->>Gitaly: tcp:// or unix: address, no certificate
    Op->>Backup: gitlab-backup sets two environment variables with the paths
    Backup->>Gitaly: tls:// address, same key and chain

References

How to set up and validate locally

Spec Examples Failures
spec/lib/gitlab/gitaly_client_spec.rb 200 0
spec/initializers/8_gitaly_spec.rb 19 0
spec/initializers/1_settings_spec.rb 87 0
spec/lib/backup/gitaly_backup_spec.rb 31 0
gems/gitlab-backup-cli gitaly_backup_spec.rb 19 0
gems/gitlab-backup-cli source_context_spec.rb 44 0

Tested on omnibus self-managed instances: startup with bad files, then, against Gitaly built with the code of the Gitaly MRs above, under require and verify_if_given, Rails reads, Sidekiq, and gitaly-backup create and restore.

An AI coding assistant wrote this change. The assistant also checked each claim against the issues and source this MR cites, ran the changed spec files and RuboCop on a GitLab development environment on a test VM, ran markdownlint and Vale on a test VM, and ran Rails reads, Sidekiq, gitaly-backup and the startup checks on self-managed GitLab 19.5.3 and 19.5.4 instances on test VMs.

Merge request reports

Loading
Loading