gstackoverflow
gstackoverflow

Reputation: 37064

LDAPException(resultCode=8 (strong auth required), diagnosticMessage='BindSimple: Transport encryption required

Now I have following code to create a new connection:

        return LDAPConnection(opts, host, port).apply {
            connectionName = "foo-$userDn-$host-$port"
            processExtendedOperation(StartTLSExtendedRequest(SSLUtil(TrustAllTrustManager()).createSSLContext()))
            bind(userDn, password)
        }      

Now I want to switch to use LDAPConnectionPool.

I tried to do this:

        val simpleBindRequest = SimpleBindRequest(userDn, password)
        val exampleConnection = LDAPConnection(opts, host, port).apply {
            connectionName = "foo-$userDn-$host-$port"
            processExtendedOperation(StartTLSExtendedRequest(SSLUtil(TrustAllTrustManager()).createSSLContext()))
            bind(simpleBindRequest )
        }      
        val ldapConnectionPool = LDAPConnectionPool(exampleConnection , 1, 10)
        ldapConnectionPool.setBindRequest(simpleBindRequest)           

later in some piece of code I do the call fir the first time

connectionPool.getConnection()

and it works because it returns initially passed connection (exampleConnection )

but when I do a call

connectionPool.getConnection()

for the second time I get LDAPException:

LDAPException(resultCode=8 (strong auth required), diagnosticMessage='BindSimple: Transport encryption required. ', ldapSDKVersion=6.0.11, revision=8b21d0a4c6eb8b5c3e60a96fc3e9e13b9c2f650f) at com.unboundid.ldap.sdk.LDAPConnectionPool.createConnection(LDAPConnectionPool.java:1388) at com.unboundid.ldap.sdk.LDAPConnectionPool.createConnection(LDAPConnectionPool.java:1269) at com.unboundid.ldap.sdk.LDAPConnectionPool.getConnection(LDAPConnectionPool.java:1866)

I suppose that it is because of

 processExtendedOperation(StartTLSExtendedRequest(SSLUtil(TrustAllTrustManager()).createSSLContext()))

is not called

Is there way to fix it ?

Upvotes: 0

Views: 40

Answers (1)

gstackoverflow
gstackoverflow

Reputation: 37064

The correct way is:

val startTLSPostConnectProcessor =
            StartTLSPostConnectProcessor(SSLUtil(TrustAllTrustManager()).createSSLContext())
val ldapConnectionPool = LDAPConnectionPool(exampleConnection , 1, 10, startTLSPostConnectProcessor)
    

Upvotes: 0

Related Questions