在PostgreSQL服务器上启用SSL连接

时间:2015-12-09 15:40:19

标签: postgresql ssl-certificate

我正在尝试将我的PowerBI与postgreSQL数据库连接。出于这个原因,我需要启用SSL连接。 到目前为止,我已经创建了documentation中提到的server.key和server.crt文件 我还使用以下参数修改了postgresql.conf文件:

#authentication_timeout = 1min      # 1s-600s
ssl = on                # (change requires restart)
#ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers
                    # (change requires restart)
#ssl_prefer_server_ciphers = on     # (change requires restart)
#ssl_ecdh_curve = 'prime256v1'      # (change requires restart)
ssl_cert_file = 'server.crt'        # (change requires restart)
ssl_key_file = 'server.key'     # (change requires restart)
#ssl_ca_file = ''           # (change requires restart)
#ssl_crl_file = ''          # (change requires restart)
#password_encryption = on
#db_user_namespace = off
#row_security = on

但我没有成功,我错过了什么?

Postgres版本:9.5 WIndows 8

我正在使用ODBC来测试与SSL的连接是否真的有效,并且你可以看到它并不是: enter image description here

我想弄清楚如何让它运行,但如果我可以强制Power BI不使用SSL连接,我也会很高兴。如果有人知道该怎么做,请告诉我!

修改 更多信息:pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD
# IPv4 local connections:
#host    all             all             127.0.0.1/32            md5
hostssl    all             all             127.0.0.1/32            md5
# IPv6 local connections: host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5

1 个答案:

答案 0 :(得分:0)

您没有提及从源代码重新构建Postgres,因为它在您引用的文档的第一段中是必需的:

  

PostgreSQL本身支持使用SSL连接进行加密   客户端/服务器通信以提高安全性。这需要   OpenSSL安装在客户端和服务器系统上   在构建时启用PostgreSQL支持(参见第15章)。

(强调我的)

如果您尝试使用预先打包的发行版(例如RPM或Debian软件包)使其工作,则不会编译SSL支持,因此您无法使用。

您需要确保已安装OpenSSL,并从源重建PostgreSQL,并将--with-openssl命令行选项添加到源树配置中,如15.4. Installation Procedure中所述。

有关必要安装过程的更完整说明,请参阅Chapter 15. Installation from Source Code