Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 37B0D632933 for ; Tue, 20 Oct 2009 00:45:44 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 71464-08 for ; Tue, 20 Oct 2009 03:45:36 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by mail.postgresql.org (Postfix) with ESMTP id 6664D6327E2 for ; Tue, 20 Oct 2009 00:45:35 -0300 (ADT) Received: from [10.0.0.53] (wallace.localnet [10.0.0.53]) by mail.postnewspapers.com.au (Postfix) with ESMTP id AD83C1E0440; Tue, 20 Oct 2009 11:45:32 +0800 (WST) Subject: Re: How to ensure that SSL is enabled? From: Craig Ringer To: Eric Jain Cc: pgsql-jdbc@postgresql.org In-Reply-To: References: Content-Type: multipart/alternative; boundary="=-rAbWRJOy6bNbmP0m6rHh" Date: Tue, 20 Oct 2009 11:45:32 +0800 Message-Id: <1256010332.6437.74.camel@wallace.localnet> Mime-Version: 1.0 X-Mailer: Evolution 2.26.1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.598 tagged_above=-10 required=5 tests=BAYES_00=-2.599, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200910/20 X-Sequence-Number: 20022 --=-rAbWRJOy6bNbmP0m6rHh Content-Type: text/plain Content-Transfer-Encoding: 7bit On Mon, 2009-10-19 at 17:31 -0700, Eric Jain wrote: > I've appended ?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory > to the connection URL, but (looking at the network traffic) no > encryption appears to be done. Shouldn't the connection fail if no SSL > connection can be established? It's possible that the server isn't set > up properly; is there a simple way to test that (e.g. verify that the > server was compiled with SSL support etc)? > It looks like on the JDBC side is mostly handled via custom SSLFactory classes. There's been discussion of making the "ssl" param take a string value, allowing more control over behaviour: http://archives.free.net.ph/message/20070706.205109.cdd3ca05.en.html ... but I don't know if much ever came of it. Personally, I handle this on the server side in pg_hba.conf . For Internet users (0.0.0.0/0 IP/mask), I use "hostssl" entries rather than simple "host" entries, so the pg_hba.conf entry only matches for SSL connections. If they're not using SSL, the server won't let them try password auth because there's no pg_hba.conf entry that'd permit them to do so. eg: hostssl somedatabase all 0.0.0.0/0 md5 -- Craig Ringer --=-rAbWRJOy6bNbmP0m6rHh Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 7bit On Mon, 2009-10-19 at 17:31 -0700, Eric Jain wrote:
I've appended ?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
to the connection URL, but (looking at the network traffic) no
encryption appears to be done. Shouldn't the connection fail if no SSL
connection can be established? It's possible that the server isn't set
up properly; is there a simple way to test that (e.g. verify that the
server was compiled with SSL support etc)?


It looks like on the JDBC side is mostly handled via custom SSLFactory classes. There's been discussion of making the "ssl" param take a string value, allowing more control over behaviour:

http://archives.free.net.ph/message/20070706.205109.cdd3ca05.en.html

... but I don't know if much ever came of it.

Personally, I handle this on the server side in pg_hba.conf . For Internet users (0.0.0.0/0 IP/mask), I use "hostssl" entries rather than simple "host" entries, so the pg_hba.conf entry only matches for SSL connections. If they're not using SSL, the server won't let them try password auth because there's no pg_hba.conf entry that'd permit them to do so.

eg:

    hostssl    somedatabase    all    0.0.0.0/0    md5

--
Craig Ringer --=-rAbWRJOy6bNbmP0m6rHh--