use of com.unboundid.util.ssl.HostNameSSLSocketVerifier in project keywhiz by square.
the class LdapConnectionFactory method getLDAPConnection.
public LDAPConnection getLDAPConnection(String userDN, String password) throws LDAPException, GeneralSecurityException {
TrustStoreTrustManager trust = new TrustStoreTrustManager(trustStorePath, trustStorePassword.toCharArray(), trustStoreType, false);
LDAPConnectionOptions options = new LDAPConnectionOptions();
options.setSSLSocketVerifier(new HostNameSSLSocketVerifier(false));
SSLUtil sslUtil = new SSLUtil(trust);
SocketFactory factory = new EndpointIdentificationSocketFactory(sslUtil.createSSLSocketFactory("TLSv1.2"));
LDAPConnection ldapConnection = new LDAPConnection(factory, options);
// Connect, retrieve the DN of the user (if any)
ldapConnection.connect(server, port);
ldapConnection.bind(userDN, password);
return ldapConnection;
}
Aggregations