【问题标题】:Having trouble setting up Postgres server to accept SSL connections设置 Postgres 服务器以接受 SSL 连接时遇到问题
【发布时间】:2016-07-01 13:16:13
【问题描述】:

我在 Mac 上使用 Postgres.app 运行 Postgres 服务器。

我正在 Node.js 中连接到服务器(代码从 Heroku docs 复制):

pg.defaults.ssl = true;
pg.connect(process.env.DATABASE_URL || 'postgres://localhost:5432/my-project', function(err, client) {
  if (err) throw err;
  console.log('Connected to postgres! Getting schemas...');

  client
    .query('SELECT table_schema,table_name FROM information_schema.tables;')
    .on('row', function(row) {
      console.log(JSON.stringify(row));
    });
});

然后我按照说明here 允许我的 Postgres 服务器接受 SSL 连接。我在postgresql.conf 文件中将ssl 设置更改为on。我还生成了所需的文件,server.keyserver.crt

但是,当我运行我的节点服务器时,我收到了这个错误:

Error: The server does not support SSL connections

我跑了psql 并做了show ssl。它返回off。所以我想也许我有错误的配置文件......但后来我做了show config_file,我绝对是在正确的地方。我还缺少什么?

【问题讨论】:

    标签: node.js postgresql


    【解决方案1】:

    您很可能忘记重新启动 PostgreSQL 服务器。
    如果出现问题,设置log_connections = on并检查PostgreSQL服务器日志。

    【讨论】:

    • 不,我确实重新启动了...退出 Postgres 应用程序后找不到任何进程或连接到 psql。
    • 日志中也没有任何内容?然后要么你不小心连接到了错误的服务器,要么 PostgreSQL 在没有 SSL 支持的情况下被编译;运行pg_config --configure 找出答案。
    • 嗯...我觉得很傻。发现了我的问题。我忘记在我的配置文件中删除ssl = on 行中的#
    猜你喜欢
    • 1970-01-01
    • 2013-08-09
    • 2019-11-19
    • 1970-01-01
    • 2018-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-07
    相关资源
    最近更新 更多