Topic
  • No replies
mset
mset
2 Posts

Pinned topic trying to establish a SSL connection for a java Application to the LDAP Ser

‏2011-03-18T17:05:29Z |
I am trying to establish a SSL connection for a java Application to the LDAP Server using "ibmjnd.jar"

I get the following error:
==========================
javax.naming.ConfigurationException: java.lang.ClassNotFoundException: error loading SSL keyring file ldapkey
at com.ibm.jndi.LDAPCtx.LDAPInit(LDAPCtx.java:639)
at com.ibm.jndi.LDAPCtx.<init>(LDAPCtx.java:89)
at com.ibm.jndi.LDAPCtxFactory.getInitialContext(LDAPCtxFactory.java:18)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at javax.naming.directory.InitialDirContext.<init>(Unknown Source)
at nl.ingbank.orgexport.util.pec.LDAPConnector.getConnection(LDAPConnector.java:70)
at nl.ingbank.orgexport.employee.Employee.getLDAPConnection(Employee.java:258)
at nl.ingbank.orgexport.employee.Employee.<init>(Employee.java:135)
at nl.ingbank.orgexport.sq.ExportEmployeeDataSQ.getTree(ExportEmployeeDataSQ.java:350)
at nl.ingbank.orgexport.sq.ExportEmployeeDataSQ.execute(ExportEmployeeDataSQ.java:296)
at nl.ingbank.orgexport.sq.ExportEmployeeDataSQ.main(ExportEmployeeDataSQ.java:582)
Following is the code that I am using to make a call to an LDAP server and authenticate the user.
=================================================================================================

private void getLDAPConnection() throws NamingException {

String factory = "com.ibm.jndi.LDAPCtxFactory";
String authentication = properties.getProperty("ldap.LDAPauth");
String url = properties.getProperty("ldap.LDAPurl");
String principal = properties.getProperty("ldap.LDAPid");
String credentials = properties.getProperty("ldap.LDAPpwd");

String keystore =
properties.getProperty (PROPERTY_KEY_STORE, "C:/.....security/crt/ldapkey.kdb" );

//THE LOCATION OF THE CACERTS MUST BE SPECIFIED
System.setProperty("javax.net.ssl.keyStore", keystore);
System.setProperty("javax.net.ssl.trustStore", keystore);
try {
Properties env = new Properties();
env.put("java.naming.factory.initial", factory);
env.put("java.naming.provider.url", url);

env.put(javax.naming.Context.SECURITY_AUTHENTICATION, authentication);
env.put(javax.naming.Context.SECURITY_PRINCIPAL, principal);
env.put(javax.naming.Context.SECURITY_CREDENTIALS, credentials);

env.put("java.naming.security.protocol", "ssl");

ctx = new javax.naming.directory.InitialDirContext(env);
} catch (NamingException e) {
log.error(e);
}
}