Kerberos uses the IP instead of hostname

1.9k Views Asked by At

I'm writing a Java class to access to Solr (with SolrJ) in a Kerberized Cloudera Virtual Machine with a static IP address (I'm using VMWare) from a windows machine. The problem is that Kerberos returns me the following error: Server not found in Kerberos database (7) - UNKNOWN_SERVER.

This is the complete error:

KRBError:
     cTime is Sun Mar 06 03:49:00 CET 1994 762922140000
     sTime is Thu Dec 29 16:11:14 CET 2016 1483024274000
     suSec is 413432
     error code is 7
     error Message is Server not found in Kerberos database
     cname is cloudera@CLOUDERA
     sname is HTTP/192.168.59.200@CLOUDERA
     msgType is 30

The problem is that Kerberos uses the IP address of the Virtual Machines (in which Kerberos is installed) instead of the FQDN (= quickstart.cloudera). In fact in Kerberos exists only HTTP/quickstart.cloudera@CLOUDERA principal.

I also tried to rename the service principal from HTTP/quickstart.cloudera@CLOUDERA to HTTP/192.168.59.200@CLOUDERA and it worked, but I broke all cloudera's internal services that use the HTTP original principal.

In the windows hosts file I put: 192.168.59.200 quickstart.cloudera

This is my krb5.conf:

[libdefaults]
default_realm = CLOUDERA
rdns = true
dns_lookup_kdc = true
dns_lookup_realm = true
dns_canonicalize_hostname = true
ignore_acceptor_hostname = true
ticket_lifetime = 86400
renew_lifetime = 604800
forwardable = true
default_tgs_enctypes = rc4-hmac
default_tkt_enctypes = rc4-hmac
permitted_enctypes = rc4-hmac
udp_preference_limit = 1
kdc_timeout = 3000
[realms]
CLOUDERA = {
  kdc = quickstart.cloudera
  admin_server = quickstart.cloudera
  default_domain = quickstart.cloudera
}
[domain_realm]
  .cloudera = CLOUDERA
  quickstart.cloudera = CLOUDERA

This is my jaas.conf:

com.sun.security.jgss.initiate {
 com.sun.security.auth.module.Krb5LoginModule required
 useKeyTab=true
 keyTab="C:/Binaries/Kerberos/cloudera.keytab"
 doNotPrompt=true
 useTicketCache=false
 storeKey=true
 debug=true
 principal="cloudera@CLOUDERA";
};

And this is my java test code:

@Test
public void testSecureSolr() {
try {

    System.setProperty("sun.security.krb5.debug", "true");
     System.setProperty("java.security.krb5.conf","C:\\Binaries\\Kerberos\\krb5.conf");
System.setProperty("java.security.auth.login.config","C:\\Binaries\\Kerberos\\jaas.conf");

    LOG.info("-------------------------------------------------");
    LOG.info("------------------- TESTS SOLR ------------------");
    LOG.info("-------------------------------------------------");

    HttpClientUtil.setConfigurer(new Krb5HttpClientConfigurer());

    SolrServer solrServer = new HttpSolrServer(CLUSTER_URI_SOLR);
    SolrPingResponse pingResponse = solrServer.ping();

    LOG.info("Solr Ping Status: "+ pingResponse.getStatus());
    LOG.info("Solr Ping Time: "+ pingResponse.getQTime());

} catch (SolrServerException | IOException e) {
    e.printStackTrace();
}
}

Any suggestion? Thanks.

0

There are 0 best solutions below