HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMajor

Force PostgreSQL clients to use SSL?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqlsslforceclientsuse

Problem

I have configured ssl = on in postgresql.conf (and installed a certificate etcetera). Does this ensure that all clients will always connect over SSL?

(I.e. does ssl = on it make it impossible to connect without SSL encryption?)

Are there other ways to ensure that all clients always connect over SSL/TLS?

Solution

ssl = on only enables the possibility of using SSL.

To ensure that all clients are using SSL, add hostssl lines in pg_hba.conf, e.g.,

hostssl  all  all  0.0.0.0/0  md5


and remove all host lines. (Well, maybe keep the ones for localhost.)

If the desire is to force the client to send a certificate, then md5 has to be changed to cert. e.g.,

hostssl  all  all  0.0.0.0/0  cert

Code Snippets

hostssl  all  all  0.0.0.0/0  md5
hostssl  all  all  0.0.0.0/0  cert

Context

StackExchange Database Administrators Q#8580, answer score: 44

Revisions (0)

No revisions yet.