powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / JNDI+LDAP= OK , а как сделать JNDI+LDAP & SSL ?
1 сообщений из 1, страница 1 из 1
JNDI+LDAP= OK , а как сделать JNDI+LDAP & SSL ?
    #32745511
Фотография insect
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Вот понадобилось использовать Novell LDAP.
Попробовал следующий код:
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
import javax.naming.*;
import javax.naming.directory.*;

import java.util.Hashtable;

 /**
 * Demonstrates how to create an initial context to an LDAP server
 * using simple authentication.
 *
 * usage: java Simple
 */ 
class Simple {
    public static void main(String[] args) {

    Hashtable env = new Hashtable(11);
    env.put(Context.INITIAL_CONTEXT_FACTORY, 
	    "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://10.10.11.2/o=NameTree");

    env.put(Context.SECURITY_AUTHENTICATION, "simple");

  
    env.put(Context.SECURITY_PRINCIPAL, "cn=User, ou=ServerName, o=NameTree");
	env.put(Context.SECURITY_CREDENTIALS, "UserPassword");

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

	try {
	     // Create initial context 
	    DirContext ctx = new InitialDirContext(env);

	    System.out.println(ctx.lookup("ou=ServerName"));


	     // do something useful with ctx 

	     // Close the context when we're done 
	    ctx.close();
	} catch (NamingException e) {
	    e.printStackTrace();
	}
    }
}


Всё отлично срабатывает, но в данном случае пароль передается открытым текстом, а это не есть хорошо.
Попытка убрать комментарий в строке с SSL приводит к ошибке:
Error JDeveloper
javax.naming.CommunicationException: simple bind failed: 10.1.1.2:636 [Root exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found]

at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:198)

.........................

Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
.........................

... 12 more

Caused by: sun.security.validator.ValidatorException: No trusted certificate found
.........................

... 24 more

Process exited with exit code 0.



Ничего не могу найти в документации по JNDI от SUN про этот сертификат...

При решении проблемы, описанной в ---Realm Tomcat & Novell LDAP--- для создания Realm (через LDAP) в Tomcat я просто объявил digest algorithm MD5 и всё...
А где здесь брать этот сертификат?

Electronic Insect
...
Рейтинг: 0 / 0
1 сообщений из 1, страница 1 из 1
Форумы / Java [игнор отключен] [закрыт для гостей] / JNDI+LDAP= OK , а как сделать JNDI+LDAP & SSL ?
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]