Connecting to a DB that requires SSL using Delphi 7

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for PostgreSQL in Delphi and C++Builder
Post Reply
mdehaij
Posts: 8
Joined: Mon 13 Jan 2014 13:08

Connecting to a DB that requires SSL using Delphi 7

Post by mdehaij » Fri 06 Feb 2015 12:35

Hi,

We are having trouble to connect to a Postgres 9.2 database that only accepts SSL connections. If I read the documentation correctly this isn't possible using Delphi 7, but please correct me if I am wrong! Making a connection to this database using your Delphi 2007 driver is not a problem, it's only in Delphi 7 that we cannot connect.
Error message was something like "invalid username/password" (our DB admin changes our server settings so I cannot check anymore). Can you tell me please if I missed a connection property that I should set?

Another question: using Delphi 2007 with SSLMode parameter set to REQUIRE, I can connect to a database that only has the host property set (and not the sslhost). Shouldn't this be impossible?

Thanks in advance!
Martin de Haij

Below is the relevant text from the readme.html that's included with the driver installation:

SSLMode

This option determines whether or with what priority an SSL connection will be negotiated with the server. There are four modes:
Value Meaning
DISABLE Only an unencrypted SSL connection will be attempted.
ALLOW Negotiates trying first a non-SSL connection, then if that fails, tries an SSL connection.
PREFER Negotiates trying first an SSL connection, then if that fails, tries a regular non-SSL connection.
REQUIRE Tries only an SSL connection.

If PostgreSQL is compiled without SSL support, using option REQUIRE will cause an error, while options ALLOW and PREFER will be accepted but PgDAC will not in fact attempt an SSL connection.

It is available for Delphi 2007 and higher IDE versions.

SQLConnection1.Params.Values['SSLMode'] := 'REQUIRE';

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Connecting to a DB that requires SSL using Delphi 7

Post by azyk » Thu 12 Feb 2015 10:24

mdehaij wrote:We are having trouble to connect to a Postgres 9.2 database that only accepts SSL connections. If I read the documentation correctly this isn't possible using Delphi 7, but please correct me if I am wrong! Making a connection to this database using your Delphi 2007 driver is not a problem, it's only in Delphi 7 that we cannot connect.
You understood everything correctly.The SSLMode advanced option of the driver for connection to PostgreSQL via SSL has been supported since RAD Studio 2007. So this option is not supported in Delphi 7.
mdehaij wrote:Another question: using Delphi 2007 with SSLMode parameter set to REQUIRE, I can connect to a database that only has the host property set (and not the sslhost). Shouldn't this be impossible?
Such a situation can occur in case when the TSQLConnection.LoadParamsOnConnect connection property is set to True, and in the dbxdrivers.ini file in the driver section (for example, [DevartPostgreSQL]) required options are set for connection to PostgreSQL via SSL.

mdehaij
Posts: 8
Joined: Mon 13 Jan 2014 13:08

Re: Connecting to a DB that requires SSL using Delphi 7

Post by mdehaij » Mon 16 Feb 2015 09:27

THANK YOU for the reply, we are with one application unfortunately still stuck with Delphi 7 so we'll have to find another way (SSL tunnel maybe) to connect to the database. Our other applications can use your DBX 4.0 driver :)

"Another question: using Delphi 2007 with SSLMode parameter set to REQUIRE, I can connect to a database that only has the host property set (and not the sslhost). Shouldn't this be impossible?"
>> Such a situation can occur in case when the TSQLConnection.LoadParamsOnConnect
>> connection property is set to True, and in the dbxdrivers.ini file in the driver
>> section (for example, [DevartPostgreSQL]) required options are set for connection to
>> PostgreSQL via SSL.

The TCRSQLConnection.LoadParamsOnConnect is set to False and never changed in our code.
Is it possible for PostgreSQL to support SSL without setting the sslhost property perhaps?

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Connecting to a DB that requires SSL using Delphi 7

Post by azyk » Tue 24 Feb 2015 08:10

Using only the host option in the pg_hba.conf file you can enable support for SSL, since the host option corresponds to connections via TCP/IP using SSL or non-SSL. See more details in the PostgreSQL documentation: http://www.postgresql.org/docs/9.2/stat ... -conf.html .

mdehaij
Posts: 8
Joined: Mon 13 Jan 2014 13:08

Re: Connecting to a DB that requires SSL using Delphi 7

Post by mdehaij » Tue 24 Feb 2015 09:06

Thanks again, that explains it then :)

Post Reply