Gino: Binding postgres url with sslcert and sslmode does not work

Created on 9 Nov 2018  路  4Comments  路  Source: python-gino/gino

  • GINO version: 0.800
  • Python version: 3.6.5
  • asyncpg version: 0.18.1
  • aiocontextvars version: 2.3
  • PostgreSQL version: 10.5

Description

async def main(): await db.set_bind(f'postgres://admin:[email protected]:18629/prod?sslmode=verify&sslcert={ctx}')

Keeps throwing this error.
asyncpg.exceptions.InvalidAuthorizationSpecificationError: no pg_hba.conf entry for host " ", user "admin", database "prod", SSL off

question

All 4 comments

From the error message, it looks like pg_hba.conf is not correctly configured. You may want to take a look at https://www.postgresql.org/docs/11/auth-pg-hba-conf.html

sslmode=verify&sslcert={ctx} - I don't think these two args are acceptable, ~let me check~.

The two arguments are from libpq, and inherited by psycopg2. GINO uses asyncpg, therefore this won't work. You'll probably need something like this:

    ctx = ssl.SSLContext(...)
    // create and configure your SSL context
    await db.set_bind('postgres://admin:[email protected]:18629/prod', ssl=ctx)

See here for docs about ssl.

@fantix Should I submit a PR with some more examples of how to connect to the db including this one? Thanks again. Really great tool

Sure. Thanks!

Was this page helpful?
0 / 5 - 0 ratings