java2db

Solution to SSLHandshakeException (skip the certificate for Java and LDAP bind)



While connecting a java client with LDAP , it may get SSLHandshakeException or CommunicationException .To avoid this , add SSL certificate or write a java class that skip the SSL certificate verification .

 

In the below example , we created java classes to skip or disable the SSL certificate check to avoid SSLHandshakeException.

 

SSLHandshakeException (skip the certificate for Java and LDAP bind) Steps to skip the certificate verification to avoid SSLHandshakeException :

  Step 1 :

create the below  java classes under specific package (Ex : ldapApp) using any IDE (Eclipse , NetBeans , MyEclipse or RAD) or stand alone.

 

 

DummyTrustmanager.java

MySSLSocketFactory.java

SSLHandshakeException (skip the certificate for Java and LDAP bind)  Step 2 :

Set MySSLSocketFactory.java class to Hashtable ( Authentication credentials ).

environment.put(“java.naming.ldap.factory.socket”, “ldapApp.MySSLSocketFactory”);

cmnLdapImpl .java

SSLHandshakeException (skip the certificate for Java and LDAP bind)  Step 3 :

Run the above java class like  stand alone  java application . Finally you will get  “Bind successful”  message on the output console.

 

SSLHandshakeException (skip the certificate for Java and LDAP bind)  Change URL , AdminDn , password  according to your LDAP settings. 



Related Posts :
How to Connect to Oracle from Liferay portlet ( Java Liferay and Oracle integration )
How to Connect Liferay 7 to PostgreSQL ( Java Liferay portlet and PostgreSQL integration )
How to call C# .Net WCF web service in java SOAP client ( Visual Studio 2013 )
How to call PHP RESTful web service in java client
How to call java SOAP web service in php ( php web service client )
Java RESTful web service example in maven using JAX-RS
RESTful web service example in java using JAX-RS
Create a java web service from WSDL (Top down approach) in Eclipse
   [will not be published]



^ <