Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 970679ED581 for ; Wed, 7 Dec 2011 12:28:15 -0400 (AST) Received: from lo.gmane.org ([80.91.229.12]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RYKLu-00087c-4V for pgsql-jdbc@postgresql.org; Wed, 07 Dec 2011 16:28:15 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RYKLg-00063u-Hz for pgsql-jdbc@postgresql.org; Wed, 07 Dec 2011 17:28:00 +0100 Received: from cpc10-with5-2-0-cust74.1-4.cable.virginmedia.com ([86.26.85.75]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 07 Dec 2011 17:28:00 +0100 Received: from bruno by cpc10-with5-2-0-cust74.1-4.cable.virginmedia.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 07 Dec 2011 17:28:00 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Bruno Harbulot Subject: Re: JDBC with SSL Date: Wed, 07 Dec 2011 16:27:47 +0000 Lines: 55 Message-ID: <4EDF9403.9060400@distributedmatter.net> References: <4EDC1031.2010607@ringerc.id.au> <4EDD65BC.4010605@ringerc.id.au> <4EDEF445.10006@ringerc.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org Cc: Craig Ringer X-Gmane-NNTP-Posting-Host: cpc10-with5-2-0-cust74.1-4.cable.virginmedia.com User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: <4EDEF445.10006@ringerc.id.au> X-Pg-Spam-Score: -5.4 (-----) X-Archive-Number: 201112/37 X-Sequence-Number: 22491 On 07/12/2011 05:06, Craig Ringer wrote: > On 07/12/11 03:43, Walter Hurry wrote: >> On Tue, 06 Dec 2011 08:45:48 +0800, Craig Ringer wrote: >> >>> On 12/06/2011 02:46 AM, Walter Hurry wrote: >>>> ------------------------------------------------------------- $ java >>>> -Djavax.net.ssl.keyStore=$HOME/.postgresql/clientstore \ >>>> -Djavax.net.ssl.keyStorePassword=changeit \ >>>> -Djavax.net.ssl.keyStoreType="jks" \ >>>> >>> I thought you could only use a JECKS store when including private keys? >> Sorry, I'm pretty new to all this. What is a JECKS store? Does it mean I >> have the keyStoreType wrong? > > JKS and JECKS are two different key store formats. Keytool understands > both. If my memory serves, JECKS is the encrypted keystore format, > intended for storing private key data. I think you can use JECKS for > both certificate and key data, but you can use JKS only for certificate > data, NOT for key data. You can store certificates and/or private keys in both JKS and JECKS. PKCS12 is somewhat different in that, to store a certificate (or a certificate chain), it requires there to be a private key associated with this certificate. Java isn't the only implementation with this limitation, but I must admit I can't remember what the PKCS#12 specification itself says about it. More details on JKS/JECKS, from: http://docs.oracle.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html#KeystoreImplementation > jceks" is an alternate proprietary keystore format to "jks" that uses much stronger encryption in the form of Password-Based Encryption with Triple-DES. The default keystore type with the Oracle security provider is JKS; you can check this using KeyStore.getDefaultType(). If your initial key and certs where in PEM format (as used by psql), it might be easier to build a PKCS#12 store with OpenSSL: openssl pkcs12 -export -in usercert.pem -inkey userkey.pem -out usercreds.p12 You can then use it with KeyStore type "PKCS12" (no #) from Java directly. You could also convert this PKCS#12 file into a JKS/JECKS keystore using keytool and its -importstore options (only in Java 6+). Best wishes, Bruno.