Skip to content

Usage of ?sslmode=require and ssl property in pg.Pool #3355

Description

@albertpurnama

I have the following code snippet

    const pool = new pg.Pool({
      connectionString: env.DATABASE_URL,
      ssl: env.DATABASE_CA_CERT
        ? {
            ca: env.DATABASE_CA_CERT,
            rejectUnauthorized: true,
          }
        : undefined,
    });

seems like a pretty standard setup. I have downloaded CA_CERT from DigitalOcean managed database product.

I copied the connection string which includes the ?sslmode=require query parameter at the end.

I experience the error:

Error: self-signed certificate in certificate chain

It seems like the query param sslmode=require completely overrides the ssl property setting. I confirmed this by removing the sslmode=require and the pool got connected normally.

Can anyone explain a little bit deeper on why this is the case? I might miss some stuff, but if sslmode=require is set on the connection string, how should one set the CA cert for the connection pool?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions