pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: PG-JDBC Mailing List <pgsql-jdbc@postgresql.org>
Subject: New code: Easy PKCS#12 client certificate support for pgjdbc
Date: Wed, 12 May 2010 20:15:00 +0800
Message-ID: <4BEA9BC4.4040607@postnewspapers.com.au> (raw)

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



view thread (2+ messages)  latest in thread

Message-ID: <4BEA9BC4.4040607@postnewspapers.com.au>
Permalink:  ../4BEA9BC4.4040607@postnewspapers.com.au/
Also on:    postgresql.org/message-id/4BEA9BC4.4040607@postnewspapers.com.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: craig@postnewspapers.com.au
  Subject: Re: New code: Easy PKCS#12 client certificate support for pgjdbc
  In-Reply-To: <4BEA9BC4.4040607@postnewspapers.com.au>
  References: <4BEA9BC4.4040607@postnewspapers.com.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox