In the course of using client certificates for authentication, I decided to use not -commons-SSL-0.3.11.jar yet . This led to another problem - a simple act of calling the constructor on EasySSLProtocolSocketFactory
or StrictSSLProtocolSocketFactory
will StrictSSLProtocolSocketFactory
an exception.
Code highlighted in a simple cmd application:
public class CertTest { public static void main(String[] args) { System.setProperty("javax.net.debug", "ssl,handshake");
}}
To isolate problems with old libraries, I put the above code in a directory with these banks (these are ONLY banks in the classpath):
- HttpClient-4.0.1.jar
- not yet-Common-SSL-0.3.11.jar
- Common-HttpClient-3.1.jar
- httpcore-4.0.1.jar
So, with some client certificates in the cacerts
keystore, I get: org.apache.commons.ssl.ProbablyBadPasswordException: Probably bad JKS-Key password: java.security.UnrecoverableKeyException: Password must not be null
If I use keytool
to remove all client certificates that I downloaded, the exception changes to
** Caused by: java.security.KeyStoreException: there are no private keys in the keystore! **
at org.apache.commons.ssl.KeyStoreBuilder.validate (KeyStoreBuilder.java:269)
at org.apache.commons.ssl.KeyStoreBuilder.build (KeyStoreBuilder.java:129)
at org.apache.commons.ssl.KeyMaterial. (KeyMaterial.java:179)
at org.apache.commons.ssl.KeyMaterial. (KeyMaterial.java:170)
at org.apache.commons.ssl.KeyMaterial. (KeyMaterial.java:160)
at org.apache.commons.ssl.KeyMaterial. (KeyMaterial.java:64)
at org.apache.commons.ssl.KeyMaterial. (KeyMaterial.java:114)
at org.apache.commons.ssl.KeyMaterial. (KeyMaterial.java:89)
at org.apache.commons.ssl.SSL. (SSL.java:142)
at org.apache.commons.ssl.SSLClient. (SSLClient.java:59)
at org.apache.commons.ssl.HttpSecureProtocol. (HttpSecureProtocol.java:55)
at org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory. (EasySSLProtocolSocketFactory.java:94)
Output fragments:
keyStore: /usr/java/jdk1.6.0_11/jre/lib/security/cacerts
keyStore type: jks
KeyStore provider:
init keystore
init keymanager type SunX509
trustStore: /usr/java/jdk1.6.0_11/jre/lib/security/cacerts
Type trustStore: jks
TrustStore Provider:
init truststore
add as a trusted certificate:
Subject: CN = SwissSign Platinum CA - G2, O = SwissSign AG, C = CH
Issuer: CN = SwissSign Platinum CA - G2, O = SwissSign AG, C = CH
Algorithm: RSA; Serial number: 0x4eb200670c035d4f
there is a whole bunch of default default certificates ...
initiate SecureRandom sowing
SecureRandom sowing done
@@@@@@@@@@AN EXCEPTION
java.security.KeyStoreException: there are no private keys in the keystore!
Any ideas?
Sunny
source share