tags:

views:

53

answers:

1

Trying to query ldap over an ssl connection. I was sent a certificate and ran

keytool -import -trustcacerts -alias www.the-domain.com -file the-cert.der -keystore store.jks

I then pointed my java program at the cert by adding the following to the run configuration in intellij

-Djavax.net.ssl.trustStore=/path/to/store.jks

I get a socket closed exception when I try to connect. Did I miss a step? Thanx...

here is the st, slightly modified so no IP info

javax.naming.ServiceUnavailableException: <ip:port>; socket closed
at com.sun.jndi.ldap.Connection.readReply(Connection.java:419)
at com.sun.jndi.ldap.LdapClient.ldapBind(LdapClient.java:340)
at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:192)
at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2694)
at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:293)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:82)
at LDAPTool.main(LDAPTool.java:35)
A: 

I found out what my issue was. I didn't set up my environment correctly.

env.put(Context.SECURITY_PROTOCOL, "ssl");

when using ssl evidently you need to specify the security protocol, which makes sense....

hvgotcodes