I'm trying to connect to ldap server using SASL. I'm connecting using url ldaps://ldap.example.com
but server hostname is host.example.com
. ldap.example.com
is cname for host.example.com
. My program is trying to get service ticket for ldap/ldap.example.com
instead of performing reverse dns request and getting ticket for ldap/host.example.com
. Everything works fine when I'm using ldap://host.example.com
but I prefer to use service CNAME.
There is my code for creating connection factory:
public DefaultConnectionFactory connectionFactory(){
return new DefaultConnectionFactory(connectionConfig());
}
private ConnectionConfig connectionConfig(){
final SaslConfig saslConfig = new SaslConfig();
saslConfig.setMechanism(Mechanism.GSSAPI);
final BindConnectionInitializer connectionInitializer = new BindConnectionInitializer();
connectionInitializer.setBindSaslConfig(saslConfig);
ConnectionConfig connConfig = new ConnectionConfig("ldaps://ldap.example.com");
connConfig.setConnectionInitializer(connectionInitializer);
return connConfig;
}
and jaas.config:
com.sun.security.jgss.initiate {
com.sun.security.auth.module.Krb5LoginModule required
doNotPrompt=true
keyTab="/etc/ldap.keytab"
principal="[email protected]"
storeKey=true
useKeyTab=true
debug=true
;
};
Is there any way to change this behavior?
You should request a new certificate with ldap.example.com
as the subject name and with host.example.com
as a subject alternative name. The certificate negotiation is handled right before Kerberos.
A couple more suggestions:
LDAP/ldap.example.com
LDAP/host.example.com
ldap.example.com
host.example.com
principal="[email protected]"
I suggest it should be: principal=“ldap/host.example.com“;
See further reading on GSSAPI.