On Tue, 22 Nov 2016 12:45:40 +0100, Christoph Zwerschke wrote:

> This should also work with the DB API 2 module, right?

It does, but it's the database argument, which is not first in the list,
so you need something like this:

db = pgdb.connect(database='host=myinsecurehost port=12345
sslmode=require dbname=postgres password=password001')

although these also work:

db = pgdb.connect(':host=myinsecurehost port=12345 sslmode=require
dbname=postgres password=password001:::')

db = pgdb.connect(None, None, 'password001', 'myinsecurehost:12345',
'sslmode=verify-ca dbname=postgres')

db.cursor().execute('show server_version').fetchall()
[['9.5.5']]

That server requires me to send an x509 certificate as well as a
password. If I try to connect from a host where I don't have that
certificate, I get an error:

pg.InternalError: FATAL:  connection requires a valid client certificate

So, client certificate sending works. And trying to connect to a db
which doesn't have ssl set up results in

pg.InternalError: server does not support SSL, but SSL was required

Incidentally, a little security tip -- password1 has been broken, so I
recommend using a more secure password, such as password001.

If this finds you before the week-end, have a good one.

-- 
Patrick TJ McPhee <[email protected]>


_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql

Reply via email to