Received: from maia.hub.org (maia-1.hub.org [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id E405B632D41 for ; Wed, 12 May 2010 09:15:19 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 81480-09 for ; Wed, 12 May 2010 12:15:05 +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 1F1C46328A3 for ; Wed, 12 May 2010 09:15:11 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id A4636AF4AB for ; Wed, 12 May 2010 20:14:57 +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 Sqm+51cuGR8o for ; Wed, 12 May 2010 20:14:51 +0800 (WST) Received: from [192.168.3.115] (ayaki.local [192.168.3.115]) (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 583DEAEE4A for ; Wed, 12 May 2010 20:14:51 +0800 (WST) Message-ID: <4BEA9BC4.4040607@postnewspapers.com.au> Date: Wed, 12 May 2010 20:15:00 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Lightning/1.0b1 Thunderbird/3.0.4 MIME-Version: 1.0 To: PG-JDBC Mailing List Subject: New code: Easy PKCS#12 client certificate support for pgjdbc 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=-0.001 tagged_above=-10 required=5 tests=BAYES_20=-0.001 X-Spam-Level: X-Archive-Number: 201005/31 X-Sequence-Number: 20515 Hi folks I've been wrestling with certificate management in Java (as relates to PgJDBC) for a while as part of an app I'm working on, and have settled on a solution I'm happy with. It's general enough that it'll be very useful to other people here, so I've split it out into a separate library. It's intended for use with PgJDBC as an alternate sslfactory= in the jdbc url/Properties to simplify use of client certificates. Certs may be specified using the sslfactoryarg url parameter / Properties key. This provider is not Pg or JDBC specific and doesn't depend on either though. You can use it anywhere you use SSL/TLS with client certs and you want PKCS#12 support. It's really just an SSLSocketFactory that uses PKCS#12 files to provide certificate trust as well as user public and private keys for client certificate authentication. It verifies that the server being connected to has a certificate trust path to one of the CA certificates in the PKCS#12 file. If asked by the server, it will authenticate the client end against the server using the PKCS#12 file's client cert details. It is completely independent of the Java `cacerts' trust list, any .jks files installed, etc. Feeding it your own certificate source requires implementing a one-method interface that returns an InputStream. You can grab it from github if you want to have a play. I'm interested in improving the interface, and would be happy to accept changes to add an additional trusted cert list (.der / .pem file). There's a demo in the `demo' package. BE WARNED: This code is NOT well tested, and I am fairly new to the Java SSL APIs. This thing might trust 'goatse.cx' for all I know. Be very careful. Grab code here: git://github.com/ringerc/pkcs12provider.git -- Craig Ringer