我也遇到过这个问题。 对于那些将来会遇到这个问题的不幸的人,这个问题的另一个原因是通过ip访问服务器而不是它的A记录(主机名)
当您在同一台计算机上运行客户端和服务器时,可能会发生这种情况。当您使用IE与运行tomcat的机器通信时,请确保这些是不同的机器。
此外,您需要确保服务器计算机已加入keytab(testdomain.ourcompany.co.uk)中指定的域,或者您可能会退回到NTLM。即使您的服务器位于未加入域的计算机上,您的密钥表仍然可以正常工作(您将看到您显示的好密钥表解密),但IE可能会感到困惑,而不是做正确的事情。
AD只是非常喜欢为Server 2003说arcfour-hmac,所以你需要确保在krb5.ini文件中正确设置它。
您可以像这样正确创建keytab:
C:\>ktpass -princ HTTP/ourweb.testdomain.ourcompany.co.uk@TESTDOMAIN.OURCOMPANY.CO.UK -mapuser ourweb.testdomain.ourcompany.co.uk@TESTDOMAIN.OURCOMPANY.CO.UK -crypto RC4-HMAC-NT -ptype K RB5_NT_PRINCIPAL -pass * -out ourweb.keytab Targeting domain controller: test-dc.ourcompany.co.uk Using legacy password setting method Successfully mapped HTTP/ourweb.testdomain.ourcompany.co.uk@TESTDOMAIN.OURCOMPANY.CO.UK to ourweb.testdomain.ourcompany.co.uk. Key created. Output keytab to ourweb.keytab: Keytab version: 0x502 keysize 75 HTTP/ourweb.testdomain.ourcompany.co.uk@TESTDOMAIN.OURCOMPANY.CO.UK ptype 1 (KRB5_NT_PRINCIPAL) vno 3 etype 0x17 (RC4-HMAC) keylength 16 (0x0fd0e500225c4fca9a63a9998b17ca32)
我没有看到你设置了krb5.ini文件。您需要在服务器计算机上正确设置该设置(默认位置C:\ WINDOWS \ krb5.ini):
[domain_realm] .testdomain.ourcompany.co.uk = TESTDOMAIN.OURCOMPANY.CO.UK testdomain.ourcompany.co.uk = TESTDOMAIN.OURCOMPANY.CO.UK [libdefaults] default_realm = TESTDOMAIN.OURCOMPANY.CO.UK permitted_enctypes = aes128-cts aes256-cts arcfour-hmac-md5 default_tgs_enctypes = aes128-cts aes256-cts arcfour-hmac-md5 default_tkt_enctypes = aes128-cts aes256-cts arcfour-hmac-md5 [realms] VERDAD.LOCAL = { kdc = test-dc.ourcompany.co.uk admin_server = test-dc.ourcompany.co.uk default_domain = TESTDOMAIN.OURCOMPANY.CO.UK }
您可能还需要设置以下属性(如果您尝试从IDE运行此属性):
<systemProperties> <java.security.krb5.kdc>test-dc.ourcompany.co.uk</java.security.krb5.kdc> <java.security.krb5.realm>TESTDOMAIN.OURCOMPANY.CO.UK</java.security.krb5.realm> </systemProperties>
我正在使用maven的org.codehaus.mojo插件,它在pom文件中设置如下:
<build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <configuration> <server>tomcat-development-server</server> <port>8080</port> <path>/SecurityTest</path> <systemProperties> <java.security.krb5.kdc>test-dc.ourcompany.co.uk</java.security.krb5.kdc <java.security.krb5.realm>TESTDOMAIN.OURCOMPANY.CO.UK</java.security.krb5.realm> </systemProperties> </configuration> </plugin> </plugins> </build>
我也有同样的问题,花了很长时间才找到罪魁祸首。因此,如果您已完成上述所有操作,仍然使用NTLM令牌而不是kerberos。确保你没有重复的SPN。在我的情况下,我有2个帐户映射到相同的SPN,原因是我以前在同一台服务器上运行一个单独的Web应用程序,使用不同的服务帐户,但映射到相同的SPN,这是HTTP /
希望能帮助到你