Finding JNDI/LDAP Connection Security Protocol

'javax.net.debug - Debugging SSL Socket Communication' tutorial was cited in a stackoverflow forum post in 2016.

The javax.net.debug - Debugging SSL Socket Communication tutorial was cited in a stackoverflow forum post in 2016.

Subject: Finding JNDI/LDAP Connection Security Protocol
Date: Dec 19, 2016
Author: Olivier T
Source: http://stackoverflow.com/questions/41167721
   /finding-jndi-ldap-connection-security-protocol

>I'm using java (8) to connect to an LDAP-Server to get some
>information. I'm doing this over SSL but I cannot figure out if my
>specified security protocol is actually being used....
>
>Here is my code:
>   LdapContext ctx = null;
>   Hashtable<String, String> env = new Hashtable <String, String>();
>   try{
>       env.clear();
>       env.put(Context.INITIAL_CONTEXT_FACTORY,
>          "com.sun.jndi.ldap.LdapCtxFactory");
>       env.put(Context.SECURITY_PRINCIPAL, "user");
>       env.put(Context.SECURITY_CREDENTIALS, "password");
>       env.put(Context.SECURITY_PROTOCOL, "ssl");
>       env.put("com.sun.jndi.ldap.read.timeout", 5000);
>       env.put("com.sun.jndi.ldap.connect.timeout", 5000);
>       env.put(Context.PROVIDER_URL, "myurl");
>       ctx = new InitialLdapContext(env, null);
>   } catch(NamingException nex) {
>       ...
...

According to your link (
http://docs.oracle.com/javase/8/docs/technotes/guides/jndi
/jndi-ldap-gl.html), the only value for java.naming.security.protocol
is "ssl".

With Context.SECURITY_PROTOCOL="ssl" :
•it opens a secure SSL/TLS connexion if the serveur supports it
•it fails with a javax.net.ssl.SSLHandshakeException otherwise

With Context.SECURITY_PROTOCOL=any other word than "ssl", it opens a
simple connection (with no SSL/TLS)

So, with the standard factory (com.sun.jndi.ldap.LdapCtxFactory) and
with "ssl" param, you use a SSL/TLS connexion or do nothing.

You can see a lot of details of your connection with the parameter
-Djava.net.debug=ssl and can see which version of TLS and cipher is
used by your connection. (see https://www.herongyang.com/JDK
/SSL-Socket-Communication-Debug-javax-net-debug.html)

Table of Contents

 About This Book

 Reference Citations in 2023

 Reference Citations in 2022

 Reference Citations in 2021

 Reference Citations in 2020

 Reference Citations in 2019

 Reference Citations in 2018

 Reference Citations in 2017

Reference Citations in 2016

 Java Server Accepts TLS 1.2 Only

 cliente soap java

 Android Hints Tweaks and Tips

 [Tutorial] - Play HD Videos with ffplay

 Comment ouvrir les fichiers XML

 Počítačová síť a internet

 Deploying Embarcadero Delphi XE7 and C++ Builder XE7 Applications

 Change XSD root namespace in BizTalk

 Заставить пример java + ssl работать

 字符编码的故事:ASCII,GB2312,Unicode,UTF-8,UTF-16

 General Relativity for Laypeople – A First Primer

 XML Dynamic Key Encryption Approach

 Подключение к MS SQL Server из NetBeans

 TCP SSL 서버 성능테스트 관련 질문

 Tạo cửa sổ con nằm trong cửa sổ tab chính trong Java

 FAQ DMP Compatibilité

 How does PHP determine the character encoding in browser POST request data?

 Implementing the Information Security using Modified RSA

 Recording Video of an Android Device

 Getting error for SOAP request "InvalidSecurity: ..."

 SSL证书链包如何工作?

Finding JNDI/LDAP Connection Security Protocol

 how to import x509.pem pk8 file into jks(keystore)

 Reference Citations in 2015

 Reference Citations in 2014

 Reference Citations in 2013

 Reference Citations in 2012

 Reference Citations in 2011

 Reference Citations in 2010

 Reference Citations in 2009

 Reference Citations in 2008

 Reference Citations in 2007

 Reference Citations in 2006

 Reference Citations in 2005

 Reference Citations in 2004

 Reference Citations in 2003