Java 无法从 Linux 客户端的缓存中获取 TGT

ric*_*_ru 5 java kerberos openldap

我已经在 RHEL5.5 中设置了 Kerberos 服务器和 OpenLDAP。我还有一台 RHEL6 机器作为客户端。我已经运行了我的 Java 程序,jaas用于从 Linux 客户端查询 OpenLDAP 服务器。

如果将客户端的密钥表复制到客户端计算机并使用以下配置选项,则可以查询 OpenLDAP 服务器:

principal=wpingli
useKeyTab=true
keyTab="/home/wpingli/ker/java/wpingli_new.keytab";
Run Code Online (Sandbox Code Playgroud)

如果提示我输入用户/密码,我也可以查询 OpenLDAP 服务器。这让我相信我的环境没问题。

但是,如果我在以下之后运行 Java 程序,则无法查询服务器kinit

klist
[wpingli@pli java]$ klist
Ticket cache: FILE:/tmp/krb5cc_500
Default principal: wpingli@XX.COM
Valid starting Expires Service principal
10/20/11 16:18:06 10/21/11 16:18:02 krbtgt/XX.COM@XX.COM

jaas configuration
GssExampleSUN{
com.sun.security.auth.module.Krb5LoginModule required
client=true
debug=true
doNotPrompt=true
useTicketCache=true
ticketCache="/tmp/krb5cc_500";
};

Exception:
Debug is true storeKey false useTicketCache true useKeyTab false doNotPrompt true ticketCache is /tmp/krb5cc_500 isInitiator true KeyTab is null refreshKrb5Config is false principal is null tryFirstPass is false useFirstPass is false storePass is false clearPass is false
Acquire TGT from Cache
Principal is null
**null credentials from Ticket Cache
[Krb5LoginModule] authentication failed
Unable to obtain Princpal Name for authentication
Authentication attempt failedjavax.security.auth.login.LoginException: Unable to obtain Princpal Name for authentication**
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

Bru*_*uno 5

Java 不一定支持(大概是 MIT)kinit( libkrb5)支持的所有加密类型。

它可以配置使用的加密类型libkrb5krb5.conf的文件(在一般情况/etc)。例如(不一定是最安全的):

# default_tgs_enctypes = aes256-cts arcfour-hmac-md5 des3-hmac-sha1 des-cbc-crc des-cbc-md5
default_tgs_enctypes = des3-hmac-sha1 des-cbc-crc des-cbc-md5

# default_tkt_enctypes = aes256-cts arcfour-hmac-md5 des3-hmac-sha1 des-cbc-crc des-cbc-md5
default_tkt_enctypes = des3-hmac-sha1 des-cbc-crc des-cbc-md5

# permitted_enctypes = aes256-cts arcfour-hmac-md5 des3-hmac-sha1 des-cbc-crc des-cbc-md5
permitted_enctypes = des3-hmac-sha1 des-cbc-crc des-cbc-md5
Run Code Online (Sandbox Code Playgroud)

支持哪些加密类型取决于 JRE 供应商/版本及其安全提供者。

这是 Java 6 (Oracle JRE) 文档的链接: