postgres=# \dx sslinfo
List of installed extensions
Name | Version | Schema | Description
---------+---------+--------+------------------------------------
sslinfo | 1.2 | public | information about SSL certificates
(1 row)
6.重启生效
pg_ctl restart
7.配置pg_hba
...
hostssl all all 0.0.0.0/0 scram-sha-256
8.配置生效
pg_ctl reload
9.测试登录
$ psql postgres://postgres@pg01:5666/postgres?sslmode=require
psql (16.3)
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off)
Type "help" for help.
postgres=# show ssl
;
ssl
-----
on
(1 row)
postgres=# SELECT * FROM pg_stat_ssl WHERE pid = pg_backend_pid();
pid | ssl | version | cipher | bits | client_dn | client_serial | issuer_dn
-------+-----+---------+------------------------+------+-----------+---------------+-----------
29321 | t | TLSv1.3 | TLS_AES_256_GCM_SHA384 | 256 | | |
(1 row)
postgres=# select ssl_is_used();
ssl_is_used
-------------
t
(1 row)