Hi,
After trying out SQLite and MS SQL Server and figuring out the actual needs that my program has, I selected PostgreSQL to go forward with. I've got it (temporarily) installed on Windows and I managed to compile the QPSQL driver with help of some posts of this forum. The next step was to establish SSL secured connection to the data base from my app using following functions:
db.setDatabaseName("test");
db.setHostName("localhost");
db.setUserName("tester");
db.setPassword("****");
db.setPort(5432);
db.setConnectOptions("requiressl=1");
if (!db.open()) {
tr("Unable to establish a database connection.\n"
return;
}
db.setDatabaseName("test");
db.setHostName("localhost");
db.setUserName("tester");
db.setPassword("****");
db.setPort(5432);
db.setConnectOptions("requiressl=1");
if (!db.open()) {
QMessageBox::critical(0, tr("Cannot open database"),
tr("Unable to establish a database connection.\n"
), QMessageBox::Cancel);
return;
}
To copy to clipboard, switch view to plain text mode
So far so good. Connection is established and SQL commands work as expected. However, I was wondering that how to check the servers certificates? Isn't there some function for that? I know that the connection is ciphered even without checking the certificate, but it would good also to know that my app is not connecting to some middle-man. I know checking the certificate is possible if one uses SSL Sockets, but what about with QPSQL?
Second question: I have enabled the SSL by modifying the postgresql.conf file and as I said the connection succeeds with SSL. But how to force it to use SSL in the server side? Now it accepts both connection requests using SSL and those that are not using SSL. Not sure if this is important, because in my app I'll use the "requiressl=1" option anyway and it does not matter whether some unwanted connection attempts use SSL or not - I think...
Cheers!
Bookmarks