Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id CF404B5D803 for ; Tue, 28 Jun 2011 20:42:44 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 90885-06 for ; Tue, 28 Jun 2011 23:42:38 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [173.230.139.50]) by mail.postgresql.org (Postfix) with ESMTP id 8884BB5D91F for ; Tue, 28 Jun 2011 20:42:38 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by www.postnewspapers.com.au (Postfix) with ESMTP id AC3FD37; Tue, 28 Jun 2011 19:42:37 -0400 (EDT) X-Virus-Scanned: amavisd-new at postnewspapers.com.au.com Received: from www.postnewspapers.com.au ([127.0.0.1]) by localhost (www.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id gAxVjOlXaVn1; Tue, 28 Jun 2011 19:42:36 -0400 (EDT) Received: from mail.postnewspapers.com.au (ppp171-128.static.internode.on.net [150.101.171.128]) by www.postnewspapers.com.au (Postfix) with ESMTP id 623CA27; Tue, 28 Jun 2011 19:42:36 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 55BFBAE525; Wed, 29 Jun 2011 07:42:35 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id J5sUskHxyxPp; Wed, 29 Jun 2011 07:42:30 +0800 (WST) Received: from [10.1.1.5] (203-206-78-208.dyn.iinet.net.au [203.206.78.208]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id B5E7CAE522; Wed, 29 Jun 2011 07:42:29 +0800 (WST) Message-ID: <4E0A66E4.8010903@postnewspapers.com.au> Date: Wed, 29 Jun 2011 07:42:28 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc15 Thunderbird/3.1.10 MIME-Version: 1.0 To: Eyal Edri CC: pgsql-jdbc@postgresql.org Subject: Re: PgJDBC - Using certificate auth with jboss & postgres References: <022601cc35a4$1780fde0$4682f9a0$@redhat.com> In-Reply-To: <022601cc35a4$1780fde0$4682f9a0$@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/74 X-Sequence-Number: 21998 On 06/28/2011 11:00 PM, Eyal Edri wrote: > Hi, > > I'm trying to make postgres and jboss JBoss version? > work together using certificate authentication method and SSL. Possibly stupid question: Why? In almost all cases with application servers the appserver is on the same machine as the DB or on the same network segment, so few people even bother using SSL let alone client cert auth. If the app server is cracked, the attacker can dump the certificate and private key just as easily as they can dump the pool's username and password, so you don't gain much by using cert auth in security terms either. > I've read some recent posts that this functionality is going to > implemented (?) but I couldn't find documentation about how to implement > it. It'd really help if you provided links to the documents you're referring to. Anyway, client cert auth already works with an unmodified PgJDBC. The code/discussion you saw recently was probably the custom SSLSocketFactory intended to make it easier to specify your own KeyStore location and customize the process. With current PgJDBC, you just use standard JSSE parameters to specify a keystore and add your keys to that store. I'd be astonished if JBoss AS didn't already have a KeyStore, so you probably don't have to go messing with JSSE parameters. As for adding keys to the store, if JBoss doesn't provide its own key management interfaces you'd use the standard java keytool command. Note that keys in a JBoss-wide keystore would be visible and accessible to all applications running on the server. If that is not acceptable, you'll have to use a custom SSLSocketFactory to load your chosen KeyStore. Example code is on the mailing list (and will make it into PgJDBC soon hopefully). In the mean time you can make your own jar with your SSLSocketFactory, put it in the same directory as the appserver's copy of PgJDBC and refer to it using the sslsocketfactory jdbc datasource parameter. It's also worth noting that Pg had a bug where it didn't tell the client which CA certificate it expected client certs to be signed by. Java couldn't figure out which certificate to offer if it had more than one in the KeyStore, because Pg didn't give it the information required to decide. This bug is fixed, I just can't remember whether it was fixed in 8.4 or 9.0. -- Craig Ringer