Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 7E025B5DC20 for ; Wed, 18 May 2011 04:02:39 -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 53489-08 for ; Wed, 18 May 2011 07:02:32 +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 25D78B5DC1F for ; Wed, 18 May 2011 04:02:32 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by www.postnewspapers.com.au (Postfix) with ESMTP id A9D9BEB; Wed, 18 May 2011 03:02:31 -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 ThI3FbDUPBbB; Wed, 18 May 2011 03:02:31 -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 B2B7427; Wed, 18 May 2011 03:02:30 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 7362BAE857; Wed, 18 May 2011 15:02:29 +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 TJyPjPZT1HCM; Wed, 18 May 2011 15:02:23 +0800 (WST) Received: from [10.1.1.3] (124-169-254-58.dyn.iinet.net.au [124.169.254.58]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 977D7AE3F6; Wed, 18 May 2011 15:02:23 +0800 (WST) Message-ID: <4DD36EFC.6070707@postnewspapers.com.au> Date: Wed, 18 May 2011 15:02:20 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 To: =?windows-1252?Q?Marc-Andr=E9_Laverdi=E8re?= CC: pgsql-jdbc@postgresql.org Subject: Re: Support for cert auth in JDBC References: <4DD34FE5.3020609@atc.tcs.com> <4DD35BEA.3020902@postnewspapers.com.au> <4DD361CA.3070907@atc.tcs.com> In-Reply-To: <4DD361CA.3070907@atc.tcs.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit 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: 201105/49 X-Sequence-Number: 21879 On 18/05/2011 2:06 PM, Marc-André Laverdière wrote: > Hello, > > This implementations allows to specify which keystore and which > truststore to load. This allows certificate authentication in the > application easily. It's already pretty easy. You can: - Load your keys in the standard keystore; - Populate a new JECKSf-format keystore with your cert and key and use the javax.net.ssl.trustStore etc system properties on the cmdline or via System.setProperty() to use that store instead of the default store; - Provide your own javax.net.ssl.SSLSocketFactory that wraps the default implementation with any additional behavior you need. PgJDBC could use some documentation/examples for the latter option, but it shouldn't need any changes to the PgJDBC code. > The Java SSL API is not very well known to the JDBC driver developers > and we would be interested in any interesting and generally useful > extensions that you have implemented using this mechanism. Specifically > it would be nice to be able to provide client certificates to be > validated by the server. > > > What I'm talking about is this factory referred to in the last paragraph. OK, so you've just written an easy-to-use canned SSLSocketFactory that loads client certificates from an application-configurable keystore/truststore? I did this in my app to allow it to use a PKCS#12 format X.509 certificate directly and it was a pretty low-pain procedure. It'd be nice to have more general purpose examples in the PgJDBC sources, though. Maybe I should dig out the examples I posted to this mailing list a while ago and submit them, too? I'm not one of the PgJDBC developers, but I'd be happy to have a look at what you've done and see if I can be of any help, provide useful feedback, etc. It'd probably be best if you published your work as a patch ("diff") against PgJDBC CVS HEAD, posting the patch to this mailing list so people can look at it and try it. Make sure the email you send the patch in clearly explains the reason for any change to the existing PgJDBC code, and if you do change the core PgJDBC code make sure it passes any tests and that it compiles under the oldest supported JDK. -- Craig Ringer Tech-related writing at http://soapyfrogs.blogspot.com/