connection.startTls() failed

261 Views Asked by At

I'm trying to connect to apacheds using TLS but I got a LdapOperationException:

PROTOCOL_ERROR: The server will disconnect!

Here is my code:

LdapNetworkConnection connection = null;
    LdapConnectionConfig ldapConnectionConfig = new LdapConnectionConfig();
    ldapConnectionConfig.setUseTls(true);
    ldapConnectionConfig.setLdapHost("localhost");
    ldapConnectionConfig.setLdapPort(10636);
    ldapConnectionConfig.setTrustManagers(new X509TrustManager(){
          public X509Certificate[] getAcceptedIssuers(){
              return new X509Certificate[0];
          }
          public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException{}
          public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException{}
    });

    connection = new LdapNetworkConnection(ldapConnectionConfig);
    connection.connect();

    try{
        connection.startTls();
    }catch(LdapException e){
        e.printStackTrace();
    }

what can be the problem ?

1

There are 1 best solutions below

0
On

Use port 10389, 10636 is for LDAPS connections.