JDK-8044215 : Unable to initiate SpNego using a S4U2Proxy GSSCredential (Krb5ProxyCredential)
  • Type: Bug
  • Component: security-libs
  • Sub-Component: java.security
  • Affected Version: 8u5
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2008
  • CPU: x86
  • Submitted: 2014-05-09
  • Updated: 2016-12-03
  • Resolved: 2014-10-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u40Fixed 9 b36Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
Server account has constrained delegation.
After SpNego is established with the client, GSSContext.getDelegCred() returns a GSSCredential that is wrapping a Krb5ProxyCredential
Then, trying to that GSSCredential to create another GSSContext, and call GSSContext.initSecContext. Receives the following exception:
...
Caused by: GSSException: No valid credentials provided (Mechanism level: Failure unspecified at GSS-API level (Mechanism level: Generic error (description in e-text) (60) - Client principal does not match))
  at sun.security.jgss.spnego.SpNegoContext.initSecContext(Unknown Source)
  at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
  at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
  at com.mellmo.roambi.http.auth.spnego.SPNEGOAuthScheme.authenticate(SPNEGOAuthScheme.java:368)
  ... 404 more
Caused by: GSSException: Failure unspecified at GSS-API level (Mechanism level: Generic error (description in e-text) (60) - Client principal does not match)
  at sun.security.jgss.krb5.Krb5Context.initSecContext(Unknown Source)
  at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
  at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
  at sun.security.jgss.spnego.SpNegoContext.GSS_initSecContext(Unknown Source)
  ... 408 more
Caused by: KrbException: Generic error (description in e-text) (60) - Client principal does not match
  at sun.security.krb5.KrbCred.<init>(Unknown Source)
  at sun.security.jgss.krb5.InitialToken$OverloadedChecksum.<init>(Unknown Source)
  at sun.security.jgss.krb5.InitSecContextToken.<init>(Unknown Source)
  ... 412 more

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Server account has constrained delegation.
After SpNego is established with the client, GSSContext.getDelegCred() returns a GSSCredential that is wrapping a Krb5ProxyCredential
Then, trying to that GSSCredential to create another GSSContext, and call GSSContext.initSecContext.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
expected GSSContext.initSecContext to be successful.
ACTUAL -
saw an exception
...
Caused by: GSSException: No valid credentials provided (Mechanism level: Failure unspecified at GSS-API level (Mechanism level: Generic error (description in e-text) (60) - Client principal does not match))
  at sun.security.jgss.spnego.SpNegoContext.initSecContext(Unknown Source)
  at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
  at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
  at com.mellmo.roambi.http.auth.spnego.SPNEGOAuthScheme.authenticate(SPNEGOAuthScheme.java:368)
  ... 404 more
Caused by: GSSException: Failure unspecified at GSS-API level (Mechanism level: Generic error (description in e-text) (60) - Client principal does not match)
  at sun.security.jgss.krb5.Krb5Context.initSecContext(Unknown Source)
  at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
  at sun.security.jgss.GSSContextImpl.initSecContext(Unknown Source)
  at sun.security.jgss.spnego.SpNegoContext.GSS_initSecContext(Unknown Source)
  ... 408 more
Caused by: KrbException: Generic error (description in e-text) (60) - Client principal does not match
  at sun.security.krb5.KrbCred.<init>(Unknown Source)
  at sun.security.jgss.krb5.InitialToken$OverloadedChecksum.<init>(Unknown Source)
  at sun.security.jgss.krb5.InitSecContextToken.<init>(Unknown Source)
  ... 412 more

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
I patched KrbCred.java but removing the following check:
 /*
        if (!serviceTicket.getClient().equals(client))
            throw new KrbException(Krb5.KRB_ERR_GENERIC,
                                "Client principal does not match");
        */

and I was able to proceed.