cockroachdb / cockroachdb/cockroach
cockroach sql: file .postgres/root.crt confuses cockroach sql client
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
**Describe the problem**
File `.postgres/root.crt` is required to connect to CockroachCloud clusters but it seems to interfere with `cockroach sql` when connecting to a local cluster. This does not happen with v21.2, only 22.2
**To Reproduce**
```bash
fabio: ~ $ ll .postgresql/
total 8
-rw-r--r-- 1 fabio staff 2.7K Nov 15 05:34 root.crt
fabio: ~ $
fabio: ~ $ cockroach sql --url 'postgres://ad:ad@localhost:26257/defaultdb?sslmode=require'
#
# Welcome to the CockroachDB SQL shell.
# All statements must be terminated by a semicolon.
# To exit, type: \q.
#
ERROR: failed to connect to `host=localhost user=ad database=defaultdb`: failed to write startup message (x509: certificate signed by unknown authority)
Failed running "sql"
fabio: ~ $
fabio: ~ $ mv .postgresql/root.crt .postgresql/root.crt.backup
fabio: ~ $
fabio: ~ $ cockroach sql --url 'postgres://ad:ad@localhost:26257/defaultdb?sslmode=require'
#
# Welcome to the CockroachDB SQL shell.
# All statements must be terminated by a semicolon.
# To exit, type: \q.
#
# Server version: CockroachDB CCL v22.2.2 (x86_64-apple-darwin19, built 2023/01/04 17:32:19, go1.19.1) (same version as client)
# Cluster ID: acc843e6-1e23-4e2b-9996-ae1b5b283550
#
# Enter \? for a brief introduction.
#
ad@localhost:26257/defaultdb>
```
**Environment:**
- CockroachDB version: 22.2
- Server OS: macOS
- Client app: `cockroach sql1
Jira issue: CRDB-23401
Contributor guide
Research direction
Start at the cockroach sql client connection setup and reproduce the supplied command with .postgresql/root.crt present, then again after moving it. Trace how the client discovers and uses root.crt for local and CockroachCloud connections; done means local SSL connections work with the file present without breaking Cloud connectivity.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100