How do I make my Qt PostgreSQL driver for Mac support SSL?

  • Hi folks,

    I've been wondering how to make SSL connections work from my Qt application to a PostgreSQL database. I've already followed the steps listed here to build my PSQL driver for Qt -> PostgreSQL (Qt 4.7.3, PostgreSQL 8.4.8), which works just fine for local and remote host connections.

    However, I'm having difficulty making an SSL connection to the PostgreSQL server (that is, a "hostssl" entry in Postgre's pg_hba.conf file). I've followed the directions at concerning the QSqlDatabase::setConnectOptions() function, and am adding the line:


    before I open the connection. However, when I try this I receive "invalid connection option "requiressl"" from the db.lastError().text() after failing to open the connection.

    The impression I have at the moment is that I didn't properly build the Qt PostgreSQL driver with SSL support, but I'm not sure where to go from here.

    My ideas:

    1. Try re-building the Qt PostgreSQL driver with a different version of PostgreSQL in the hopes that it will then support SSL.
    2. Try re-building the Qt PostgreSQL driver after re-building Qt with SSL support from OpenSSL (not sure if this is necessary if I just want SSL support through the driver).

    Does anyone know what is more likely the issue? Or perhaps something else I haven't thought of?

    Thanks for reading, and I appreciate the help.


    Additional Info: I've also built the Qt PostgreQSL driver for Windows and do not have the same issue (Qt 4.7.3 built without OpenSSL, PostgreSQL 8.4.8), making me further believe it was just the Mac driver build that went wrong somehow.

  • Issue was solved: Downloaded PostgreSQL 9.0 and re-built the Qt PostgreSQL driver with 9.0's headers and libraries. Now I can make SSL connections to PostgreSQL.

Log in to reply