Connection hacks

Determine if connection is TLS/SSL protected

Scenario: you want to determine if a particular connection is using TLS/SSL

Solution: Execute SELECT ssl FROM pg_stat_ssl WHERE pid = pg_backend_pid()

Alternatively, if the sslinfo contrib module is installed, execute SELECT ssl_is_used()