I’m currently trying to implement a Java client to an SPNEGO protected web service using the SPNEGO library from SourceForge (the server is using the same library). I can not get it to authenticate successfully, my requests always end up as
HTTP/1.1 500 Failure unspecified at GSS-API level (Mechanism level: Checksum failed)
This is similar to the symptoms that I get when accessing the web service from a browser with an inappropriate hostname, and indeed some debugging in Wireshark reveals that the client sends a wrong SPN with the request – I send to service-test.client.com, which is registered as an SPN and has an A record in DNS, but is registered in the Windows domain as server-1234.client.corp. Even though I send my request to http://service-test.client.com (see matching Host header), the SPN that Java requests a ticket for is the “internal” Windows name:

The same sent from Chrome or IE has matching Host headers and SPNs:

Since there is none of this translation occurs in my code or the SPNEGO library, I presume it must be happening somehwere in the JRE. I’ve been looking into the JGSS source, but it’s a bit hard to understand. Can anyone tell me how to skip this translation and get tickets for the correct SPN?
Client code:
SpnegoHttpURLConnection con = new SpnegoHttpURLConnection("spnego-client", user, password);
con.connect(new URL("http://service-test.client.com:8083/service"));
int rc = con.getResponseCode();
String msg = con.getResponseMessage();
Summary from the comments above:
Recheck your DNS. Do a reverse lookup. Most problems occur from incorrect reverse DNS entries.
Page 85 in RFC2713 might help you and check RFC4120 and search for “canon”.
When a SPN for a host-based service is constructed with GSS-API you have to canonicalize that name with the target mechanism. The RFC says
Where the Kerberos 5 RFC says:
It seems like GSS-API impls may canonicalize but Kerberos should not do so if the DNS is untrusted.
So it depends. It’s perfectly natural that a reverse lookup is done. This is how Kerberos verifies the hostname. This is actually crucial if you are running DNS round-robin. Without that it won’t never be able to construct the real SPN.
Though I would really as this on a Kerberos mailing list. This is a very interesting point.
I have checked the MIT Kerberos implementation and there is the method
krb5_sname_to_principalwhich actually does this if you check the source code insn2princ.c:So, I guess we have to ask with the mailing list.