drogon icon indicating copy to clipboard operation
drogon copied to clipboard

Postgresql is set to sslmode=require -> connection failed.

Open rafeeque1 opened this issue 10 months ago • 2 comments

Describe the bug void DbClientManager::addDbClient(const DbConfig &config) { if (std::holds_alternative<PostgresConfig>(config)) { #if USE_POSTGRESQL auto &cfg = std::get<PostgresConfig>(config); auto connStr = buildConnStr(cfg.host, cfg.port, cfg.databaseName, cfg.username, cfg.password, cfg.characterSet);

why we are using only host , port , databaseName, username etc only? what if my postgresql set sslmode=require , then how to include sslmode etc into connection string

ConnectionString = "dbname=defaultdb user=avnadmin password={PASSWORD} host={HOST} port=22389 sslmode=require" if sslmode=require on postgresql

To Reproduce Steps to reproduce the behavior:

  1. Go to aiven cloud (aiven.io)

  2. create a postgresql

  3. try to connect with drogon

  4. and see the error -> ERROR !!!Pg connection failed: FATAL: no pg_hba.conf entry for host {HOST}, user {USER}, database {DB_NAME}, no encryption

    PgConnection.cc:161

Desktop (please complete the following information):

  • OS: ubuntu
  • i am using drogon from conan package manager.

rafeeque1 avatar Jan 21 '25 21:01 rafeeque1

You could use the following option in the configuration file:

            //connect_options: extra options for the connection. Only works for PostgreSQL now.
            //For more information, see https://www.postgresql.org/docs/16/libpq-connect.html#LIBPQ-CONNECT-OPTIONS
            "connect_options": { "statement_timeout": "1s" }

an-tao avatar Jan 24 '25 02:01 an-tao

@an-tao i tried , but still getting error , can you please give me one example , also include if my postgresql has server.pem and server.key then how to connect along with certificate

rafeeque1 avatar Jan 25 '25 13:01 rafeeque1