@Override
    public void connect(LdapConfigBean config, final IAsyncResultHandler<ILdapClientConnection> handler) {
        final DefaultLdapClientConnection connection = new DefaultLdapClientConnection(config, socketFactory);
        connection.connect((IAsyncResult<ILdapResult> result) -> {
            if (result.isSuccess()) { // Could still be a non-success return
                ILdapResult ldapResult = result.getResult();
                if (ldapResult.getResultCode().isSuccess()) {
                    handler.handle(AsyncResultImpl.<ILdapClientConnection>create(connection));
                } else { // We don't have any fine-grained handling of exceptions, so bundle all into one.
                    handler.handle(AsyncResultImpl.<ILdapClientConnection>create(DefaultExceptionFactory.create(ldapResult)));
                }
            } else {
                handler.handle(AsyncResultImpl.<ILdapClientConnection>create(result.getError()));
            }
        });
    }
Set a custom socket factory, if needed (for TLS).
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/DefaultLdapComponent.java