startTLS should be based on ldap URL (not ldaps)
| | |
| | | * If trust manager is null, certificates are not checked during SSL |
| | | * handshake. |
| | | * |
| | | * @param ldapsURL the target *LDAPS* URL. |
| | | * @param ldapURL the target *LDAP* URL. |
| | | * @param dn passed as Context.SECURITY_PRINCIPAL if not null. |
| | | * @param pwd passed as Context.SECURITY_CREDENTIALS if not null. |
| | | * @param timeout passed as com.sun.jndi.ldap.connect.timeout if > 0. |
| | |
| | | * @see TrustedSocketFactory |
| | | */ |
| | | |
| | | public static InitialLdapContext createStartTLSContext(String ldapsURL, |
| | | public static InitialLdapContext createStartTLSContext(String ldapURL, |
| | | String dn, String pwd, int timeout, Hashtable<String, String> env, |
| | | TrustManager trustManager, KeyManager keyManager, |
| | | HostnameVerifier verifier) |
| | |
| | | } |
| | | env.put(Context.INITIAL_CONTEXT_FACTORY, |
| | | "com.sun.jndi.ldap.LdapCtxFactory"); |
| | | env.put(Context.PROVIDER_URL, ldapsURL); |
| | | env.put(Context.PROVIDER_URL, ldapURL); |
| | | env.put(Context.SECURITY_AUTHENTICATION , "none"); |
| | | |
| | | /* Contains the DirContext and the Exception if any */ |
| | |
| | | else |
| | | if (argParser.startTLS()) |
| | | { |
| | | String ldapsUrl = "ldaps://" + host + ":" + port; |
| | | String ldapUrl = "ldap://" + host + ":" + port; |
| | | try |
| | | { |
| | | ctx = ConnectionUtils.createStartTLSContext(ldapsUrl, dn, pwd, |
| | | ctx = ConnectionUtils.createStartTLSContext(ldapUrl, dn, pwd, |
| | | ConnectionUtils.getDefaultLDAPTimeout(), null, argParser |
| | | .getTrustManager(), argParser.getKeyManager(), null); |
| | | } |