Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 4ED8E632C14 for ; Thu, 3 Jun 2010 03:19:43 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 85235-09 for ; Thu, 3 Jun 2010 06:19:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [202.4.227.11]) by mail.postgresql.org (Postfix) with ESMTP id C9AA4632980 for ; Thu, 3 Jun 2010 03:19:31 -0300 (ADT) Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by www.postnewspapers.com.au (Postfix) with ESMTP id 4B1517923D; Thu, 3 Jun 2010 14:19:06 +0800 (WST) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 24855AF72D; Thu, 3 Jun 2010 14:17:41 +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 NkVNwsBBwNwg; Thu, 3 Jun 2010 14:17:35 +0800 (WST) Received: from [10.1.1.7] (124-148-251-30.dyn.iinet.net.au [124.148.251.30]) (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 60B3EAF3E9; Thu, 3 Jun 2010 14:17:35 +0800 (WST) Message-ID: <4C074967.2090305@postnewspapers.com.au> Date: Thu, 03 Jun 2010 14:19:19 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: Jeffrey Baker CC: pgsql-jdbc@postgresql.org Subject: Re: JDBC SSL with postgresql References: In-Reply-To: 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.011 tagged_above=-10 required=5 tests=BAYES_40=-0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201006/35 X-Sequence-Number: 20605 On 3/06/2010 12:08 PM, Jeffrey Baker wrote: > On Wed, Jun 2, 2010 at 5:46 PM, Jeffrey Baker wrote: >> I was interested in this[1] work on SSL client certs for JDBC, but I >> see the author stopped working on your project. I hope the list can >> give me a quick clue, because i've been banging my head against this >> all day. > > Just to update the list, I did figure this out. Turns out I hadn't > imported my private key into the keystore file. Which, in turn, is a > ridiculous pain in the butt because keytool can only deal with private > keys it generated, or those in PKCS#12 files, and in fact only in > PKCS#12 files protected with passwords. It's often easier to just point the keyStore directly at a PKCS#12 file using the javax.net.ssl.trustStoreType=pkcs12 system property. > Furthermore once the key is > in the keystore it must also have a password there (keystore password > as well as key password) or the implementation will refuse to use it! And both passwords must be the SAME. > # openssl pkcs12 -export -out client.pkcs12 -in client.cert -inkey client.key > # keytool -importkeystore -deststorepass changeit -destkeystore > client.jks -srckeystore client.pkcs12 -srcstorepass changeit > -srcstoretype PKCS12 -alias 1 -destkeypass changeit Generally, you are better off using keytool to generate the key and a certificate request, getting that certificate request signed by the CA, and importing the reply into your keystore. -- Craig Ringer