users@glassfish.java.net

Simple LDAP connection over SSL (LDAPS) fails in glassfish

From: <forums_at_java.net>
Date: Tue, 29 Nov 2011 13:06:57 -0600 (CST)

Hi,

I created a simple servlet which tried to connect to ldap over sll.
I imported the certificate into the truststore (which is defined by
-Djavax.net.ssl.trustStore in domain.xml).
I get the following error:
<code>handling exception: javax.net.ssl.SSLHandshakeException: Received fatal
alert: unknown_ca
anonymous bind failed
<code>
When I take the same code and run it outside glassfish it works (works on
tomcat, also works with no app server, just simple java code, and the
certificate is imported to jre/lib/security/cacerts).
The code is basically this:
<code>
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
String url =    "LDAPS://" + server + ":" + port ;
env.put(Context.PROVIDER_URL,url);
env.put(Context.SECURITY_AUTHENTICATION, "none");
DirContext ctx =new InitialDirContext(env);
<code>

 

I spent 4 days on it and it's very frustrating.
Any help will be appreciated...
Thanks in advance.


--
[Message sent by forum member 'Karo']
View Post: http://forums.java.net/node/869155