cockroachdb / cockroachdb/cockroach

roachprod: cert authenticated internal pgurls do not work with psql

Open
#119,661 3 comments 1 reaction 0 assignees View on GitHub
A-testeng-infra C-bug T-testeng
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Roachtests can use `c.InternalPGUrl` or `roachprod.PGUrl` to generate an internal pgurl. By default, this will return a connection string that authenticates using certificates and uses the `internalIP` for the host name.

When using `psql` in `verify-full` [mode](https://www.postgresql.org/docs/current/libpq-ssl.html#LIBQ-SSL-CERTIFICATES):

> the host name is matched against the certificate's Subject Alternative Name attribute(s) (SAN), or against the Common Name attribute if no SAN of type dNSName is present

However, since we are using the `internalIP` as our host name, it is listed in the server certs as a `iPAddress SAN`. `psql` will not find the IP in `dNSNames` and return the following error:

`psql: error: connection to server at "10.142.0.246", port 29000 failed: server certificate for "localhost" (and 1 other names) does not match host name "10.142.0.246"`

Note that `cockroach` and `workload` does not run into this issue as they check the host against both `dNSNames` and `iPAddress`.

---------

This effectively is a blocker for using certificate authenticated connection strings with `psql`. An immediate workaround would be to skip certificate authentication and use `AuthUserPassword`. This authenticates with a default user and password, and uses `ssl-mode=allow`, so the above problem is not run into.

```
c.InternalPGUrl(ctx, t.L(), c.Node(1), roachprod.PGURLOptions{Auth: install.AuthUserPassword})
```

A more long term fix would be to switch `roachprod.PGUrl` to use the `vm hostname` instead of an IP as `psql` will be able to find this in the server certs. This functionality works out of the box for `GCE` clusters, due to the internal DNS allowing nodes to connect to one another by just using the `hostname`. However, work needs to be done for `AWS` and `Azure` clusters to provide this same functionality.

Jira issue: CRDB-36272

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.