LDAP error on Tomcat privacy - TLS
I am trying to configure Realm in Tomcat to access a TLS enabled LDAP server. My main Realm config looks like this:
<Realm className = "org.apache.catalina.realm.JNDIRealm"
debug = "99"
connectionURL = "ldap: // localhost: 389 /"
userPattern = "uid = {0}, ou = People, dc = nsdl, dc = org" />
I am getting the error:
SEVERE: Catalina.start:
LifecycleException: Exception opening directory server connection:
javax.naming.AuthenticationNotSupportedException: [LDAP: error code 13 - TLS confidentiality required]
at org.apache.catalina.realm.JNDIRealm.start (JNDIRealm.java:1697)
at org.apache.catalina.core.ContainerBase.start (ContainerBase.java:1006)
at org.apache.catalina.core.StandardHost.start (StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start (ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start (StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start (StandardService.java:448)
at org.apache.catalina.core.StandardServer.start (StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start (Catalina.java:552)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (Unknown Source)
at java.lang.reflect.Method.invoke (Unknown Source)
at org.apache.catalina.startup.Bootstrap.start (Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main (Bootstrap.java:433)
I've tried many fixes without changing the problem or error message. It includes:
- change protocol in connection url with "ldaps"
- change port in connection url to 636
- adding protocol = "TLS" to scope
- moving Realm declaration from conf / server.xml (under node or engine) to META-INF / context.xml in webapp
- adding ldap.jar to server / lib
- migrating from Tomcat 5.5 to Tomcat 6.0
They each throw the same error message (although the stack trace is different in some configurations).
Any ideas?
The answer is not really related to the question posted here. The problem was related to the way Realm pointed out.
Realm was specified in a Context element contained in a file located inside the webapp in META-INF / context.xml
I didn't understand that
- Tomcat copies this file to conf / Catalina / localhost / {webapp} .xml,
- If a newer WAR file is provided for Tomcat, it will not replace {webapp} .xml with a newer version
So the reason the same error message was happening every time was because my original copy of Realm was bad and my attempts to fix it were not considered.
In fact, the Realm spec is correct as shown above. Once I cleared the stubborn file it worked fine.