Обсуждение: [HACKERS] Introducing SNI in TLS handshake for SSL connections

Поиск
Список
Период
Сортировка

[HACKERS] Introducing SNI in TLS handshake for SSL connections

От
Florin Asavoaie
Дата:
Hi,

Back in November 2013 someone suggested adding the SNI header in the TLS handshake for connections initiated by libpq using OpenSQL. There was no usecase at that point.

However, right now there is one:

I'd like to write a small "PostGreSQL router" that routes connections to a specific cluster based on the requested SNI. Maybe it is even possible to just integrate this as an option in HaProxy, didn't look how difficult it would be to do it there.

The whole point is for using PostGreSQL inside containers and being able to connect to it from anywhere. For example if you are using Docker, you could expose the default PostGreSQL port on Dockers ingress routing mesh and let it go to the router application. Then the router application will read the SNI headers and forward the connection to the appropriate container via the Docker Overlay network (and maybe optionally even do "ssl offload" at this point since the Overlay network is already encrypted).

If there's nobody against this, I can try to do the patch myself, doesn't look too difficult (I expect it to simply work by calling SSL_set_tlsext_host_name(SSL_context, PQhost(conn))) somewhere in initialize_SSL in fe-secure-openssl.c.

Thanks,
Florin.

Re: [HACKERS] Introducing SNI in TLS handshake for SSL connections

От
Peter Eisentraut
Дата:
On 4/24/17 22:26, Florin Asavoaie wrote:
> If there's nobody against this, I can try to do the patch myself,
> doesn't look too difficult (I expect it to simply work by
> calling SSL_set_tlsext_host_name(SSL_context, PQhost(conn))) somewhere
> in initialize_SSL in fe-secure-openssl.c.

I had to look up what SNI is:
https://en.wikipedia.org/wiki/Server_Name_Indication

This seems useful.

If you have a patch, please add it here:
https://commitfest.postgresql.org/14/

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services