如何生成用于Java Kerberos Http客户端进行身份验证的login.conf和krb5.ini文件,以与Active Directory Kerberos进行身份验证?

4
我想在Java应用程序中使用Kerberos对一个受IIS Kerberos保护的网站进行认证。目标是能够使用keytab文件来验证服务帐户,而不需要指定用户名和密码。 这里描述了如何使用http客户端进行Kerberos身份验证。但它需要几个特殊的配置文件login.confkrb5.ini
登录配置文件的格式在这里描述:https://docs.oracle.com/javase/8/docs/technotes/guides/security/jgss/tutorials/LoginConfigFile.html
krb5.ini文件的格式在这里描述:https://web.mit.edu/kerberos/krb5-1.12/doc/admin/conf_files/krb5_conf.html 我还发现了一些相关的软件文章(如下所列)。
但是,它们似乎都没有描述实际创建login.conf文件和用于与Active Directory配合使用的krb5.conf/krb5.ini文件的过程。
生成这些文件以在Windows Active Directory kerberos情况下使用的步骤是什么?
到目前为止,这就是我所拥有的,但我完全是根据我从朋友和网络上随机链接找到的示例来做的。

login.conf

KrbLogin {
  com.sun.security.auth.module.Krb5LoginModule required
  useKeyTab=true
  storeKey=true
  keyTab="file:///C:/kerb/kerberos500.keytab"
  useTicketCache=true
  principal="kerberos500@FUSIONIS.LIFE"
  debug=true;
};

com.sun.security.jgss.initiate {
  com.sun.security.auth.module.Krb5LoginModule required
  useKeyTab=true
  storeKey=true
  keyTab="/home/ndipiazza/lucidworks/httpclient-tester/kb.keytab"
  useTicketCache=true
  principal="kerberos500@FUSIONIS.LIFE"
  debug=true;
};

krb5.ini

[libdefaults]
    default_realm = FUSIONIS.LIFE
    default_tkt_enctypes = aes128-cts-hmac-sha1-96 rc4-hmac
    default_tgs_enctypes = aes128-cts-hmac-sha1-96  rc4-hmac
    permitted_enctypes = aes128-cts-hmac-sha1-96 rc4-hmac
    dns_lookup_realm = false
    dns_lookup_kdc = false
    ticket_lifetime = 24h
    renew_lifetime = 7d
    forwardable = true
    udp_preference_limit = 1

[realms]
FUSIONIS.LIFE = {
   kdc = 192.168.1.71
   admin_server = 192.168.1.71
}

[domain_realm]
.fusionis.life = FUSIONIS.LIFE
fusionis.life = FUSIONIS.LIFE

在Windows上创建keytab

ktpass /princ kerberos500@FUSIONIS.LIFE /pass password /ptype KRB5_NT_PRINCIPAL /out kerberos500.keytab

在Ubuntu Linux上创建KeyTab
ktutil
addent -password -p kerberos500@FUSIONIS.LIFE -k 1 -e RC4-HMAC
- it will ask you for password of kerberos500 -
wkt kerberos500.keytab
q

相关软件:

HttpClient设置凭据进行Kerberos身份验证

Java中的简单Kerberos客户端?

更改Windows文件后,krb5.ini文件在哪里消失了?


我认为在询问之后,答案是 -> 使用我提供的文档链接来学习应该在这些文件中放置什么,然后自己设置它们。找到一个示例来帮助你入手是有用的(我已经做过了)。没有命令来构建这些文件。这完全是手动的。 - Nicholas DiPiazza
1
请将您的评论转换为答案并将其自行标记为已接受。这样做是可以的。这也为那些可能正在搜索相同问题的其他人提供了指引。 - T-Heron
1个回答

4
我认为,询问之后的答案是 -> 使用我提供的文档链接来学习在这些文件中应该放置什么内容,然后自己设置。寻找一个例子来帮助你入手很有用(我已经做过了)。没有命令可以构建它们。这完全是手动操作。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接