Ahojte,
resim tu ted bohuzel na posledni chvili pripojeni k ldapu pres ssl
vrstvu. Tady je kus kodu:
Hashtable env = new Hashtable();
String result = "vse ok";
String adminName = "cn=admin,ou=users,dc=masik,dc=cz";
String adminPassword = "150linebekostikcher";
String ldapURL = "ldaps://myserver:636";
System.setProperty("javax.net.ssl.trustStore",
"/usr/local/jdk1.4.2/jre/lib/security/jssecacerts");
System.setProperty("javax.net.ssl.trustStorePassword", "heslicko");
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
//set security credentials
env.put(Context.SECURITY_AUTHENTICATION,"simple");
env.put(Context.SECURITY_PRINCIPAL,adminName);
env.put(Context.SECURITY_CREDENTIALS,adminPassword);
env.put(Context.SECURITY_PROTOCOL, "ssl");
env.put(Context.PROVIDER_URL,ldapURL);
try {
DirContext ctx = new InitialDirContext(env);
ctx.close();
} catch (javax.naming.NamingException ne) {
result = "chyba + <br/>" + ne.toString();
}
Kod hlasi:
javax.naming.CommunicationException: simple bind failed: myserver:636
[Root exception is javax.net.ssl.SSLException:
java.lang.RuntimeException: Unexpected error:
java.security.InvalidAlgorithmParameterException: the trustAnchors
parameter must be non-empty]
Nenapada Vas prosim reseni?
v tom jssecacerts mam certifikat serveru myserver (to ma presne v cname)
a klientsky certifikat.
Za odpoved predem diky
Pet