我正在尝试连接到我的Heroku,但我一直收到PostgreSQL错误。有人知道如何在连接字符串中启用SSL吗?
postgres://user:pass@host:port/database;
我一直在到处寻找它,但它似乎不是一个很受欢迎的话题。顺便说一下,我正在运行Nodejs和node-pg模块及其连接池方法:
pg.connect(connString, function(err, client, done) {
// Should work.
});
非常感谢您的评论。
发布于 2021-02-08 18:28:57
const sequelize = new Sequelize(
configuration.get("postgresConnectionString"),
{
logging: false,
dialectOptions: {
ssl: {
ca: fs.readFileSync(path.join(__dirname, "/ssl/DigiCertGlobalRootG2.crt.pem")),
rejectUnauthorized: true,
require: true,
},
},
},
);
DigiCertGlobalRootG2.crt.pem:是2个密钥的组合( BaltimoreCyberTrustRoot.crt.pem即将过期).One文件具有多个密钥,如- BEGIN CERTIFICATE -BaltimoreCyberTrustRoot.crt.pem- END CERTIFICATE - BEGIN CERTIFICATE -END CERTIFICATE- DigiCertGlobalRootG2.crt.pem -从node.js应用程序使用Sequelize ORM连接到Azure postgress。
DigiCertGlobalRootG2.crt.pem:您将从Azure portal获得它。
注意:如果不使用任何密钥,则ssl配置如下:
const sequelize = new Sequelize(
configuration.get("postgresConnectionString"),
{
logging: false,
dialectOptions: {
ssl: true,
},
},
);
注意:请检查connectionString
以sslmode=require|| ssl_ca=required: https://docs.microsoft.com/en-us/azure/mysql/concepts-certificate-rotation
结尾,在此基础上,请添加相应的SSL配置注意:您认为需要更改的内容,请告诉我
https://stackoverflow.com/questions/22301722
复制相似问题