Headscale can not connect to postgresql with SNI in used. #366

Closed
opened 2025-12-29 01:27:44 +01:00 by adam · 0 comments
Owner

Originally created by @OrvilleQ on GitHub (Nov 3, 2022).

Bug description

Can't get postgresql works with TLS and SNI.

To Reproduce

Try connect to a postgresql database with SNI in used.

Context info

Refs to this document of neon, a hosted postgresql service.

If your application or service uses golang PostgreSQL clients like pgx and lib/pg you can set sslmode=verify-full, which will cause SNI info to be sent. Most likely, this was not intentional but happened inadvertently due to the golang's TLS library API design.

But in headscale, db_ssl is defined as a bool DBssl.

ca8bca98ed/config.go (L543)

Therefore ssl_mode can only be disabled or require (psql's default), and user won't be able to connect to any hosted postgresql server depend on SNI in TLS.

I suggest we change DBssl to string to fix this issue.

Originally created by @OrvilleQ on GitHub (Nov 3, 2022). <!-- Headscale is a multinational community across the globe. Our common language is English. Please consider raising the bug report in this language. --> **Bug description** <!-- A clear and concise description of what the bug is. Describe the expected bahavior and how it is currently different. If you are unsure if it is a bug, consider discussing it on our Discord server first. --> Can't get postgresql works with TLS and SNI. **To Reproduce** Try connect to a postgresql database with SNI in used. <!-- Steps to reproduce the behavior. --> **Context info** Refs to [this]() document of neon, a hosted postgresql service. ``` If your application or service uses golang PostgreSQL clients like pgx and lib/pg you can set sslmode=verify-full, which will cause SNI info to be sent. Most likely, this was not intentional but happened inadvertently due to the golang's TLS library API design. ``` But in headscale, `db_ssl` is defined as a bool `DBssl`. https://github.com/juanfont/headscale/blob/ca8bca98edca4dced2331071ef67fa0e0b0d0942/config.go#L543 Therefore `ssl_mode` can only be `disabled` or `require` (psql's default), and user won't be able to connect to any hosted postgresql server depend on SNI in TLS. I suggest we change `DBssl` to string to fix this issue. <!-- Please add relevant information about your system. For example: - Version of headscale used - Version of tailscale client - OS (e.g. Linux, Mac, Cygwin, WSL, etc.) and version - Kernel version - The relevant config parameters you used - Log output -->
adam added the bug label 2025-12-29 01:27:44 +01:00
adam closed this issue 2025-12-29 01:27:44 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#366