Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rafeeque1 opened this issue Jan 21, 2025 · 2 comments
Open

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

rafeeque1 opened this issue Jan 21, 2025 · 2 comments

Comments

@rafeeque1
Copy link

rafeeque1 commented Jan 21, 2025

Describe the bug
void DbClientManager::addDbClient(const DbConfig &config)
{
if (std::holds_alternative(config))
{
#if USE_POSTGRESQL
auto &cfg = std::get(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.
@an-tao
Copy link
Member

an-tao commented Jan 24, 2025

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" }

@rafeeque1
Copy link
Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants