doc/administration/gitaly/tls_support.md
Gitaly supports TLS encryption. To communicate with a Gitaly instance that listens for secure
connections, use the tls:// URL scheme in the gitaly_address of the corresponding
storage entry in the GitLab configuration.
Gitaly provides the same server certificates as client certificates in TLS connections to GitLab. This can be used as part of a mutual TLS authentication strategy when combined with reverse proxies (for example, NGINX) that validate client certificate to grant access to GitLab.
You must supply your own certificates as this isn't provided automatically. The certificate corresponding to each Gitaly server must be installed on that Gitaly server.
Additionally, the certificate (or its certificate authority) must be installed on all:
If you use a load balancer, it must be able to negotiate HTTP/2 using the ALPN TLS extension.
listen_addr and an
encrypted listening address tls_listen_addr at the same time. This allows you to gradually
transition from unencrypted to encrypted traffic if necessary.{{< history >}}
{{< /history >}}
Configure Gitaly before configuring TLS support.
The process for configuring TLS support depends on your installation type.
{{< tabs >}}
{{< tab title="Linux package (Omnibus)" >}}
Create certificates for Gitaly servers.
On the Gitaly clients, copy the certificates (or their certificate authority) into
/etc/gitlab/trusted-certs:
sudo cp cert.pem /etc/gitlab/trusted-certs/
On the Gitaly clients, edit gitlab_rails['repositories_storages'] in /etc/gitlab/gitlab.rb as follows:
gitlab_rails['repositories_storages'] = {
'default' => { 'gitaly_address' => 'tls://gitaly1.internal:9999' },
'storage1' => { 'gitaly_address' => 'tls://gitaly1.internal:9999' },
'storage2' => { 'gitaly_address' => 'tls://gitaly2.internal:9999' },
}
Save the file and reconfigure GitLab.
On the Gitaly servers, create the /etc/gitlab/ssl directory and copy your key and certificate
there:
sudo mkdir -p /etc/gitlab/ssl
sudo chmod 755 /etc/gitlab/ssl
sudo cp key.pem cert.pem /etc/gitlab/ssl/
sudo chmod 644 /etc/gitlab/ssl/cert.pem
sudo chmod 600 /etc/gitlab/ssl/key.pem
# For Linux package installations, 'git' is the default username. Modify the following command if it was changed from the default
sudo chown -R git /etc/gitlab/ssl
Copy all Gitaly server certificates (or their certificate authority) to
/etc/gitlab/trusted-certs on all Gitaly servers and clients
so that Gitaly servers and clients trust the certificate when calling into themselves
or other Gitaly servers:
sudo cp cert1.pem cert2.pem /etc/gitlab/trusted-certs/
Edit /etc/gitlab/gitlab.rb and add:
gitaly['configuration'] = {
# ...
tls_listen_addr: '0.0.0.0:9999',
tls: {
certificate_path: '/etc/gitlab/ssl/cert.pem',
key_path: '/etc/gitlab/ssl/key.pem',
## Optionally configure the minimum TLS version Gitaly offers to clients.
##
## Default: "TLS 1.2"
## Options: ["TLS 1.2", "TLS 1.3"].
#
# min_version: "TLS 1.2"
},
}
Save the file and reconfigure GitLab.
Run sudo gitlab-rake gitlab:gitaly:check on the Gitaly client (for example, the
Rails application) to confirm it can connect to Gitaly servers.
Verify Gitaly traffic is being served over TLS by observing the types of Gitaly connections.
Optional. Improve security by:
gitaly['configuration'][:listen_addr] in
/etc/gitlab/gitlab.rb.{{< /tab >}}
{{< tab title="Self-compiled (source)" >}}
Create certificates for Gitaly servers.
On the Gitaly clients, copy the certificates into the system trusted certificates:
sudo cp cert.pem /usr/local/share/ca-certificates/gitaly.crt
sudo update-ca-certificates
On the Gitaly clients, edit storages in /home/git/gitlab/config/gitlab.yml to change gitaly_address to use
a TLS address. For example:
gitlab:
repositories:
storages:
default:
gitaly_address: tls://gitaly1.internal:9999
gitaly_token: AUTH_TOKEN_1
storage1:
gitaly_address: tls://gitaly1.internal:9999
gitaly_token: AUTH_TOKEN_1
storage2:
gitaly_address: tls://gitaly2.internal:9999
gitaly_token: AUTH_TOKEN_2
Save the file and restart GitLab.
On the Gitaly servers, create or edit /etc/default/gitlab and add:
export SSL_CERT_DIR=/etc/gitlab/ssl
On the Gitaly servers, create the /etc/gitlab/ssl directory and copy your key and certificate there:
sudo mkdir -p /etc/gitlab/ssl
sudo chmod 755 /etc/gitlab/ssl
sudo cp key.pem cert.pem /etc/gitlab/ssl/
sudo chmod 644 /etc/gitlab/ssl/cert.pem
sudo chmod 600 /etc/gitlab/ssl/key.pem
# Set ownership to the same user that runs Gitaly
sudo chown -R git /etc/gitlab/ssl
Copy all Gitaly server certificates (or their certificate authority) to the system trusted certificates folder so Gitaly server trusts the certificate when calling into itself or other Gitaly servers.
sudo cp cert.pem /usr/local/share/ca-certificates/gitaly.crt
sudo update-ca-certificates
Edit /home/git/gitaly/config.toml and add:
tls_listen_addr = '0.0.0.0:9999'
[tls]
certificate_path = '/etc/gitlab/ssl/cert.pem'
key_path = '/etc/gitlab/ssl/key.pem'
Save the file and restart GitLab.
Verify Gitaly traffic is being served over TLS by observing the types of Gitaly connections.
Optional. Improve security by:
listen_addr in
/home/git/gitaly/config.toml.{{< /tab >}}
{{< /tabs >}}
To update the Gitaly certificates after initial configuration:
{{< tabs >}}
{{< tab title="Linux package (Omnibus)" >}}
If the content of your SSL certificates under the /etc/gitlab/ssl directory have been updated, but no configuration changes have been made to
/etc/gitlab/gitlab.rb, then reconfiguring GitLab doesn't affect Gitaly. Instead, you must restart Gitaly manually for the certificates to be loaded
by the Gitaly process:
sudo gitlab-ctl restart gitaly
If you change or update the certificates in /etc/gitlab/trusted-certs without making changes to the /etc/gitlab/gitlab.rb file, you must:
Reconfigure GitLab so the symlinks for the trusted certificates are updated.
Restart Gitaly manually for the certificates to be loaded by the Gitaly process:
sudo gitlab-ctl restart gitaly
{{< /tab >}}
{{< tab title="Self-compiled (source)" >}}
If the content of your SSL certificates under the /etc/gitlab/ssl directory have been updated, you must
restart GitLab for the certificates to be loaded by the Gitaly process.
If you change or update the certificates in /usr/local/share/ca-certificates, you must:
sudo update-ca-certificates to update the system's trusted store.{{< /tab >}}
{{< /tabs >}}
For information on observing the type of Gitaly connections being served, see the relevant documentation.