【问题标题】:Defective token detected - IWA with SPNEGO on tomcat检测到有缺陷的令牌 - 在 tomcat 上使用 SPNEGO 的 IWA
【发布时间】:2014-07-19 03:02:52
【问题描述】:

我正在尝试使用 Tomcat 7.0.54 设置 SPNEGO r7,但是在调用时 request.getRemoteUser()

从 jsp 中,我得到以下错误:

SEVERE: Servlet.service() for servlet [ssoServlet] in context with path [/rightitnow] threw exception [GSSException: Defective token detected (Mechanism level: GSSHeader did not find the right tag)] with root cause
GSSException: Defective token detected (Mechanism level: GSSHeader did not find the right tag)
        at sun.security.jgss.GSSHeader.<init>(GSSHeader.java:97)
        at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:306)
        at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:285)
        at sun.security.jgss.spnego.SpNegoContext.GSS_acceptSecContext(SpNegoContext.java:871)
        at sun.security.jgss.spnego.SpNegoContext.acceptSecContext(SpNegoContext.java:544)
        at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:342)
        at sun.security.jgss.GSSContextImpl.acceptSecContext(GSSContextImpl.java:285)
        at net.sourceforge.spnego.SpnegoAuthenticator.doSpnegoAuth(SpnegoAuthenticator.java:444)
        at net.sourceforge.spnego.SpnegoAuthenticator.authenticate(SpnegoAuthenticator.java:283)
        at net.sourceforge.spnego.SpnegoHttpFilter.doFilter(SpnegoHttpFilter.java:229)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at com.rivermuse.server.filter.GWTCacheControlFilter.doFilter(GWTCacheControlFilter.java:43)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)

我看过这里的帖子 http://sourceforge.net/p/spnego/discussion/1003769/thread/990913cc/ "Defective token detected" error (NTLM not Kerberos) with Kerberos/Spring Security/IE/Active Directory

但我仍然无法弄清楚问题所在。

Tomcat 在 Ubuntu 12.04 LTS 上运行,我使用 domainjoin-cli 将其添加到 windows 域。 我已经在不同的操作系统(Windows XP、7、2008 Server、MacOS)上从不同的客户端(Firefox / IE / Chrome)进行了测试,每种组合的结果都不同,其中一些组合会出现上述错误,其他组合不会发出警告完全没有,但仍然无法 getRemoteUser()。

http://spnego.sourceforge.net/pre_flight.html 中执行飞行前检查,我能够成功运行 HelloKDC。

我已确保 IE 已启用 IWA,并且服务器 beer.test.co.uk 在本地 Intranet 站点列表中,并将其添加到 Firefox 中的 network.negotiate-auth.trusted-uris。

我已按照一篇关于此问题的帖子的建议检查了正向/反向 DNS,我得到以下信息:

rabbit-stew:logs $ host beer.test.co.uk
beer.test.co.uk is an alias for beer.uk.river.com.
beer.uk.river.com has address 192.168.12.236
rabbit-stew:logs $ host 192.168.12.236
236.12.168.192.in-addr.arpa domain name pointer beer.uk.river.com.

dev@beer:~/deploy/conf$ cat jaas.conf 
com.sun.security.jgss.krb5.initiate {
    com.sun.security.auth.module.Krb5LoginModule required
    doNotPrompt=true
    principal="HTTP/beer.rivertest.co.uk@TEST.CO.UK"
    useKeyTab=true
    keyTab="/home/dev/deploy/conf/tomcat.keytab"
    storeKey=true;
};

com.sun.security.jgss.krb5.accept {
    com.sun.security.auth.module.Krb5LoginModule required
    doNotPrompt=true
    principal="HTTP/beer.test.co.uk@TEST.CO.UK"
    useKeyTab=true
    keyTab="/home/dev/deploy/conf/tomcat.keytab"
    storeKey=true;
};

dev@beer:~/deploy/conf$ cat krb5.ini 
[libdefaults]
default_realm = TEST.CO.UK
default_keytab_name = FILE:/home/dev/deploy/conf/tomcat.keytab
default_tkt_enctypes = rc4-hmac,aes256-cts-hmac-sha1-96,aes128-cts-hmac-sha1-96
default_tgs_enctypes = rc4-hmac,aes256-cts-hmac-sha1-96,aes128-cts-hmac-sha1-96
forwardable=true

[realms]
TEST.CO.UK = {
        kdc = vs5gen2.test.co.uk:88
}

[domain_realm]
test.co.uk= TEST.CO.UK
.test.co.uk= TEST.CO.UK

dev@beer:~/deploy/conf$ cat login.conf 
spnego-client {
    com.sun.security.auth.module.Krb5LoginModule required;
};

spnego-server {
    com.sun.security.auth.module.Krb5LoginModule required
    storeKey=true
    isInitiator=false;
};

最让我困惑的是,当我在我的 Mac 上运行相同的代码时,我能够让 SSO 工作。

编辑:通过添加 DNS A 记录而不是别名 + 使用 kinit 在我的 Mac 上获取手动 Kerberos 票证来解决问题。

【问题讨论】:

    标签: kerberos windows-authentication spnego


    【解决方案1】:

    当 Windows 客户端没有为请求的服务发送正确的服务令牌时,我看到了这个错误。

    例如服务是 HTTP/server.example.com,但 Windows 发送不同服务的服务票证。

    使用 Windows 客户端,使用“kerbtray”实用程序验证客户端是否确实拥有服务 HTTP/...的服务令牌...

    【讨论】:

    • 正如我在上面的答案中提到的,我在我的 Mac 上使用 kinit 手动创建了一张票,这一切都开始工作了。谢谢
    【解决方案2】:

    您遇到了 DNS 问题。请与您的管理员联系。

    【讨论】:

    • 我们是一个小地方,我们本身没有系统管理员,所以我自己设置。我已将记录从别名更改为常规 A 记录,但仍然出现该错误。你能建议我试试别的吗?
    • 试试$ host &lt;hostname&gt;$ host &lt;IP&gt;。它们匹配吗?
    • 是的,它们匹配。我现在设法解决了这个问题,我没有意识到在 Mac 上我需要运行 kinit 来创建票证。
    猜你喜欢
    • 1970-01-01
    • 2023-04-11
    • 2018-04-23
    • 1970-01-01
    • 1970-01-01
    • 2011-02-27
    • 1970-01-01
    • 2019-03-12
    相关资源
    最近更新 更多