From 3ccb59e757abb774f88ebb5fab91312af76ae21e Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 13 Jun 2016 08:02:00 +0000
Subject: [PATCH] OPENDJ-2936 display a user-friendly message when using startTLS against an LDAPS connection

---
 opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPConnection.java |    4 ++++
 opendj-server-legacy/src/messages/org/opends/messages/tool.properties          |    2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPConnection.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPConnection.java
index 6e64c22..026c192 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPConnection.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPConnection.java
@@ -220,6 +220,10 @@
         logger.traceException(e);
         throw new LDAPConnectionException(LocalizableMessage.raw(e.getMessage()), e);
       }
+      if (msg == null)
+      {
+        throw new LDAPConnectionException(ERR_STARTTLS_FAILED.get(), CLIENT_SIDE_CONNECT_ERROR, null);
+      }
       ExtendedResponseProtocolOp res = msg.getExtendedResponseProtocolOp();
       resultCode = res.getResultCode();
       if(resultCode != SUCCESS)
diff --git a/opendj-server-legacy/src/messages/org/opends/messages/tool.properties b/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
index 391a70d..35804bf 100644
--- a/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
+++ b/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
@@ -2623,6 +2623,8 @@
 Do you want to launch this process automatically at the end of the upgrade?
 INFO_UPGRADE_TASK_UNABLE_TO_REMOVE_OLD_JARS_20029=Unable to determine whether the file system is case sensitive. \
   If the file system is case sensitive, then remove OpenDJ.jar and all OpenDJ_*.jar before starting the upgraded server.
+ERR_STARTTLS_FAILED_20030=StartTLS failed: the connection has been closed without receiving a response. \
+ This may indicate you tried to connect to an LDAPS port instead of the LDAP port, or that the network is down
 
 INFO_LDAP_CONN_PROMPT_SECURITY_LDAP=LDAP
 INFO_LDAP_CONN_PROMPT_SECURITY_USE_SSL=LDAP with SSL

--
Gitblit v1.10.0