Reputation: 441
Im working on an java LDAP-Client and I'm still missing some information or knowledge on how to do this properly.
My Code looks like this:
LdapContext ctx = null;
Hashtable<String, String> env = new Hashtable <String, String>();
try{
env.clear();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "url");
env.put(Context.SECURITY_PRINCIPAL, "user");
env.put(Context.SECURITY_CREDENTIALS, "password");
env.put(Context.SECURITY_PROTOCOL, "ssl");
env.put("java.naming.security.ssl.ciphers", "SSL_RSA_EXPORT_WITH_RC4_40_MD5");
ctx = new InitialLdapContext(env, null);
} catch(NamingException nex) {
// error handling
}
The following things happen at the moment:
*** ClientHello, TLSv1.2
and *** ServerHello, TLSv1
The things I'm missing right now:
Upvotes: 1
Views: 8594
Reputation: 1
which java version do you use ? It seems that ldap server does not support TLSv1.2 you should specify dedicated ssl socket factory for ldap service.
env.put("java.naming.ldap.factory.socket", CustomTLSSSLSocketFactory.class.getName);
CustomTLSSSLSocketFactory extends SSSLSocketFactory {
public CustomTLSSSLSocketFactory() {
TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
factory.init((KeyStore) null);
TrustManager[] defaultTrustManagers = factory.getTrustManagers();
// create the real socket factory
SSLContext sc = SSLContext.getInstance("TLS"); //$NON-NLS-1$
sc.init(null, defaultTrustManagers, null);
delegate = sc.getSocketFactory();
}
}
Upvotes: -1
Reputation: 18415
Scan you server first before wasting your time for stuff likely not work at all. use: https://github.com/rbsec/sslscan
It might be possible that your server support TLS 1.0 only.
Upvotes: 0