On Wed, Jun 8, 2016 at 5:41 PM, Christos Papoulas <[email protected]> wrote:
> I'm trying to connect to my own ldap server with the Apache Directory LDAP > API for java(http://directory.apache.org/api/downloads.html) and I would > like to pass a certificate to that connection. Is it possible? > the only way to pass certificate is through X509KeyManager > > Thanks, > > > On 08/06/16 15:03, Kiran Ayyagari wrote: > > > > On Wed, Jun 8, 2016 at 5:13 PM, Christos Papoulas < <[email protected]> > [email protected]> wrote: > >> Hello list, >> >> Is it possible to pass a certificate file like ssl-cert.pem to the >> LdapConnectionConfig? My sample code right now is: >> >> are you connecting to Apache Directory Server? if yes, then certificate > based authentication is > not supported. > > If you are connecting to any other server that supports certificate based > authentication then > you need to set the TrustManager and KeyManager in LdapConnectionConfig > >> public static LdapConnection createConnection(String host, int port, >> String user, String pass, boolean useSSL, boolean useSSLv3) >> throws IOException, LdapException { >> LdapConnectionConfig connectionConfig = new >> LdapConnectionConfig(); >> >> if (host == null || host.isEmpty()) { >> throw new IllegalArgumentException("Hostname is not >> specified"); >> } >> if(port <= 0) { >> throw new IllegalArgumentException("The ldap port is not >> valid"); >> } >> connectionConfig.setLdapHost(host); >> connectionConfig.setLdapPort(port); >> >> if(user!= null && user.length() > 0) { >> connectionConfig.setName(user); >> } >> if(pass != null && pass.length() > 0) { >> connectionConfig.setCredentials(pass); >> } >> if(useSSL == true) { >> connectionConfig.setUseSsl(true); >> } >> if(useSSLv3 == true) { >> connectionConfig.setSslProtocol("SSLv3"); >> } >> LdapConnection connection = new >> LdapNetworkConnection(connectionConfig); >> >> connection.connect(); >> connection.bind(); >> >> return connection; >> } >> > Kiran Ayyagari > http://keydap.com > > > Kiran Ayyagari http://keydap.com
