You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2018/05/15 22:31:05 UTC

[directory-ldap-api] 03/06: Some fixes in LdapNetworkConnection

This is an automated email from the ASF dual-hosted git repository.

elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-ldap-api.git

commit c2cebdaa13dbe41b5fea393fc588cb1807ca1baa
Author: Emmanuel Lécharny <el...@symas.com>
AuthorDate: Wed May 2 11:09:13 2018 +0200

    Some fixes in LdapNetworkConnection
---
 .../apache/directory/ldap/client/api/LdapNetworkConnection.java  | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
index 9e30e70..f9c155f 100644
--- a/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
+++ b/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
@@ -4681,7 +4681,7 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
             }
 
             // for LDAPS
-            if ( ldapSession == null )
+            if ( ( ldapSession == null ) || !connected.get() )
             {
                 connector.getFilterChain().addFirst( SSL_FILTER_KEY, sslFilter );
             }
@@ -4911,6 +4911,13 @@ public class LdapNetworkConnection extends AbstractLdapConnection implements Lda
      */
     private void writeRequest( Request request ) throws LdapException
     {
+        // If we are meant to be using a secure connection but the ssl filter isn' in the filter chain then
+        // throw immediately
+        if ( config.isUseSsl() && !ldapSession.getFilterChain().contains( "sslFilter" ) )
+        {
+            throw new InvalidConnectionException( "Attempting to send over an insecure connection" );
+        }
+
         // Send the request to the server
         WriteFuture writeFuture = ldapSession.write( request );
 

-- 
To stop receiving notification emails like this one, please contact
elecharny@apache.org.