Exception : javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated Exception : javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated java java

Exception : javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated


Expired certificate was the cause of our "javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated".

keytool -list -v -keystore filetruststore.ts

    Enter keystore password:    Keystore type: JKS    Keystore provider: SUN    Your keystore contains 1 entry    Alias name: somealias    Creation date: Jul 26, 2012    Entry type: PrivateKeyEntry    Certificate chain length: 1    Certificate[1]:    Owner: CN=Unknown, OU=SomeOU, O="Some Company, Inc.", L=SomeCity, ST=GA, C=US    Issuer: CN=Unknown, OU=SomeOU, O=Some Company, Inc.", L=SomeCity, ST=GA, C=US    Serial number: 5011a47b    Valid from: Thu Jul 26 16:11:39 EDT 2012 until: Wed Oct 24 16:11:39 EDT 2012


This error is because your server doesn't have a valid SSL certificate. Hence we need to tell the client to use a different TrustManager. Here is a sample code:

SSLContext ctx = SSLContext.getInstance("TLS");X509TrustManager tm = new X509TrustManager() {    public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException {    }    public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException {    }    public X509Certificate[] getAcceptedIssuers() {        return null;    }};ctx.init(null, new TrustManager[]{tm}, null);SSLSocketFactory ssf = new SSLSocketFactory(ctx,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);ClientConnectionManager ccm = base.getConnectionManager();SchemeRegistry sr = ccm.getSchemeRegistry();sr.register(new Scheme("https", 443, ssf));client = new DefaultHttpClient(ccm, base.getParams());


This exception will come in case your server is based on JDK 7 and your client is on JDK 6 and using SSL certificates. In JDK 7 sslv2hello message handshaking is disabled by default while in JDK 6 sslv2hello message handshaking is enabled. For this reason when your client trying to connect server then a sslv2hello message will be sent towards server and due to sslv2hello message disable you will get this exception. To solve this either you have to move your client to JDK 7 or you have to use 6u91 version of JDK. But to get this version of JDK you have to get the MOS (My Oracle Support) Enterprise support. This patch is not public.