You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@directory.apache.org by tawalisa <ta...@163.com> on 2014/12/09 05:32:01 UTC

How to use TSL?

Hi ,

I am using directory.api. And I want to using TSL. But I saw a blank page about TSL in user guide.
https://directory.apache.org/api/user-guide/5.3-start-tls.html

Could you give me an example about it?

Thanks.

Re: How to use TSL?

Posted by Emmanuel Lécharny <el...@gmail.com>.
Le 09/12/14 05:32, tawalisa a écrit :
> Hi ,
>
> I am using directory.api. And I want to using TSL. But I saw a blank page about TSL in user guide.
> https://directory.apache.org/api/user-guide/5.3-start-tls.html
>
> Could you give me an example about it?
>
> Thanks.
Sorry for the missing documentation.

Here is an exemple :

        LdapConnectionConfig tlsConfig;

        tlsConfig = new LdapConnectionConfig();
        tlsConfig.setLdapHost( "localhost" );
        tlsConfig.setLdapPort( getLdapServer().getPort() );
        tlsConfig.setTrustManagers( new NoVerificationTrustManager()
);           /// Here, you have to provide the TrustManager instance you
want to use.
        tlsConfig.setBinaryAttributeDetector( new
SchemaBinaryAttributeDetector(
            ldapServer.getDirectoryService().getSchemaManager() ) );


        LdapNetworkConnection connection = null;
        try
        {
            connection = new LdapNetworkConnection( tlsConfig );
            tlsConfig.setUseTls( true );
            connection.connect();

        ...