Description
What you are doing?
Attempting to connect to an SSL enabled db, using a provided configuration file.
config.js
module.exports = {
"postgres://myuser:[email protected]:5432/mydb",
{
"ssl": true,
"dialectOptions": {
"ssl": {
"require": true,
"rejectUnauthorized": false
}
}
}
}
This config works when used in app, ie:
// Succesfully connects to an SSL enabled postgres server.
const config = require('./config.js')
new Sequelize(config)
The same config fails in sequelize-CLI. For example running npx sequelize db:migrate
produces this error:
no pg_hba.conf entry for host "myhostip", user "myuser", database "mydb", SSL off
Note that the error says SSL is off.
This appears to be because sequelize-cli is manipulating config and introducing an error in the process. By the time migrator.js
attempts to instantiate Sequelize, config looks like this:
{
"url": "postgres://myuser:[email protected]:5432/mydb",
"options": {
"ssl": true,
"dialectOptions": {
"ssl": {
"require": true,
"rejectUnauthorized": false
}
}
},
"database": "mydb",
"host": "myhost.compute-1.amazonaws.com",
"port": "5432",
"protocol": "postgres",
"ssl": true,
"username": "myuser",
"password": "mypass",
"dialect": "postgres"
}
The breaking modification is that ssl
and dialectOptions
are now wrapped inside anoptions
object.
It seems this modified layout is not working for Sequelize.
What do you expect to happen?
When given a config file, Sequelize CLI should behave the same as Sequelize does, including when connecting to an SSL enabled server.
What is actually happening?
Sequelize CLI is not able to connect to the SSL server, but Sequelize and the app can do so.
postgres
Sequelize CLI [Node: 12.14.1, CLI: 6.2.0, ORM: 6.6.2]