title: Spring Security + LDAP throws Bad credentials error when SSL/TLS enabled, but credentials are correct
body: <p>I am using Spring Security, Spring LDAP &amp; Spring boot in a web application.</p>
  
  <p>Authentication was <strong>working fine till</strong> I enabled SSL/TSL using ldap<strong>s</strong>.</p>
  
  <p><strong>What I did to enable SSL:</strong></p>
  
  <ol>
  <li><p>Received Root + Intermediate CA certificates from security team and added below VM arguments when run this application.</p>
  
  <p><code>-Djavax.net.ssl.keyStore=&lt;path to keystore&gt; 
  -Djavax.net.ssl.keyStorePassword=pass 
  -Djavax.net.ssl.trustStore=&lt;path to keystore, same as above&gt; 
  -Djavax.net.ssl.trustStorePassword=pass</code></p></li>
  </ol>
  
  <p>2.Changed ldap url to ldap<strong>s</strong></p>
  
  <p>3.Changed ldap port from 3268 to 636</p>
  
  <ol start="4">
  <li><p>Override default authentication statregy as below</p>
  
  <p><code>LdapContextSource contextSource = new LdapContextSource();
  AbstractTlsDirContextAuthenticationStrategy statregy = new DefaultTlsDirContextAuthenticationStrategy();
  statregy.setShutdownTlsGracefully(true);
  contextSource.setAuthenticationStrategy(statregy);</code></p></li>
  </ol>
  
  <p>Even I use correct credentials, I am getting below error.
  Please note, <strong>same</strong> credentials are working fine <strong>without</strong> SSL.</p>
  
  <p><a href="https://i.stack.imgur.com/VCRco.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VCRco.png" alt="enter image description here"></a></p>
  
  <p>Am I missing anything?</p>