2017-03-06 14 views
-1

と私はHelloKeyTab.javaファイルを実行すると、私はこのエラーを取得するSPNEGO/Kerberos認証

ため、次のエラーを取得しています。私はSPNEGO/Kerberos認証のために使用している

例外は - クライアントKerberosデータベースに見つからない(6)SPNEGO-KerberosのIWA

***Exception in thread "main" javax.security.auth.login.LoginException: Client not 
found in Kerberos database (6)** 
     at com.sun.security.auth.module.Krb5LoginModule.attemptAuthentication(K 
b5LoginModule.java:763) 
     at com.sun.security.auth.module.Krb5LoginModule.login(Krb5LoginModule.j 
va:584) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl 
java:57) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce 
sorImpl.java:43) 
     at java.lang.reflect.Method.invoke(Method.java:606) 
     at javax.security.auth.login.LoginContext.invoke(LoginContext.java:762) 
     at javax.security.auth.login.LoginContext.access$000(LoginContext.java: 
03) 
     at javax.security.auth.login.LoginContext$4.run(LoginContext.java:690) 
     at javax.security.auth.login.LoginContext$4.run(LoginContext.java:688) 
     at java.security.AccessController.doPrivileged(Native Method) 
     at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java: 
87) 
     at javax.security.auth.login.LoginContext.login(LoginContext.java:595) 
     at net.sourceforge.spnego.SpnegoHttpURLConnection.<init>(SpnegoHttpURLC 
nnection.java:207) 
     at HelloKeytab.main(HelloKeytab.java:17) 
Caused by: KrbException: Client not found in Kerberos database (6) 
     at sun.security.krb5.KrbAsRep.<init>(KrbAsRep.java:76) 
     at sun.security.krb5.KrbAsReqBuilder.send(KrbAsReqBuilder.java:319) 
     at sun.security.krb5.KrbAsReqBuilder.action(KrbAsReqBuilder.java:364) 
     at com.sun.security.auth.module.Krb5LoginModule.attemptAuthentication(K 
b5LoginModule.java:735) 
     ... 14 more 
Caused by: KrbException: Identifier doesn't match expected value (906) 
     at sun.security.krb5.internal.KDCRep.init(KDCRep.java:143) 
     at sun.security.krb5.internal.ASRep.init(ASRep.java:65) 
     at sun.security.krb5.internal.ASRep.<init>(ASRep.java:60) 
     at sun.security.krb5.KrbAsRep.<init>(KrbAsRep.java:60) 
     ... 17 more* 



セットアップ、リンクやファイル。
http://spnego.sourceforge.net/
のTomcatサーバーのドメインアカウント
ユーザーリンク - - xyztest
パスワード - ****校長
- のprinc HTTP/[email protected]
1)HelloKeyTab .java - テストは、Apache Tomcatサーバ用に生成キータブ

public class HelloKeytab { 

    public static void main(final String[] args) throws Exception { 
     System.setProperty("java.security.krb5.conf", "krb5.conf"); 
     System.setProperty("sun.security.krb5.debug", "true"); 
     System.setProperty("java.security.auth.login.config", "login.conf"); 

     SpnegoHttpURLConnection spnego = null; 

     try { 
      System.out.println("11111111"); 
      spnego = new SpnegoHttpURLConnection("custom-client"); 
      spnego.connect(new URL("http://localhost:8080/DemoAuth/hello_spnego.jsp")); 
      System.out.println("2222222"); 
      System.out.println("HTTP Status Code: " 
        + spnego.getResponseCode()); 

      System.out.println("HTTP Status Message: " 
        + spnego.getResponseMessage()); 

     } finally { 
      if (null != spnego) { 
       spnego.disconnect(); 
      } 
     } 
    } 
} 

2)のkrb5.conf - ケルベロスCONFIフィギュレーションファイル

[libdefaults] 
     default_tkt_enctypes = aes256-cts aes256-cts-hmac-sha1-96 aes128-cts- hmac-sha1-96 aes128-cts rc4-hmac des3-cbc-sha1 des-cbc-md5 des-cbc-crc arcfour-hmac arcfour-hmac-md5 
     default_tgt_enctypes = aes256-cts aes256-cts-hmac-sha1-96 aes128-cts-hmac-sha1-96 aes128-cts rc4-hmac des3-cbc-sha1 des-cbc-md5 des-cbc-crc arcfour-hmac arcfour-hmac-md5 
     permitted_enctypes = aes256-cts aes256-cts-hmac-sha1-96 aes128-cts-hmac-sha1-96 aes128-cts rc4-hmac des3-cbc-sha1 des-cbc-md5 des-cbc-crc arcfour-hmac arcfour-hmac-md5 
     default_domain = CORP.XYZ.COM 

    [realms] 
     CORP.XYZ.COM = { 
       kdc = CORP.XYZ.COM 
       default_domain = CORP.XYZ.COM 
    } 

    [domain_realm] 
     CORP.XYZ.COM = CORP.XYZ.COM 

3)はlogin.conf -Login構成ファイル

​​

4)SETSPNコマンドが主

setspn -s HTTP/APPSERVER1 xyztest 
Checking domain DC=corp,DC=xyz,DC=com 

Registering ServicePrincipalNames for CN=xyztest,CN=Users,DC=corp,DC=xyz,DC=com 
     HTTP/APPSERVER1 
Updated object 

PS C:\Windows\system32> setspn -s HTTP/APPSERVER1.corp.xyz.com xyztest 
Checking domain DC=corp,DC=xyz,DC=com 

Registering ServicePrincipalNames for CN=xyztest,CN=Users,DC=corp,DC=xyz,DC=com 
     HTTP/APPSERVER1.corp.xyz.com 
Updated object 

5)のktpassコマンドを登録-to:キータブファイルを生成する

ktpass /princ HTTP/[email protected] /mapuser xyztest /pass ***** /out xyztest.keytab /crypto AES256-SHA1 /ptype KRB5_NT_PRINCIPAL 
Targeting domain controller: xyzDC1.corp.xyz.com 
Using legacy password setting method 
ktpass : Successfully mapped HTTP/APPSERVER1 to xyztest. 
At line:1 char:1 
+ ktpass /princ HTTP/[email protected] /mapuser xyztest /pass ***** 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : NotSpecified: (Successfully ma...o xyztest.:String) [], RemoteException 
    + FullyQualifiedErrorId : NativeCommandError 

Key created. 
Output keytab to xyztest.keytab: 
Keytab version: 0x502 
keysize 84 HTTP/[email protected] ptype 1 (KRB5_NT_PRINCIPAL) vno 3 etype 0x12 (AES256-SHA1) keylength 32 
(0x6e6afbbefc78946121bd7ed6657524c7409917cae1708223ce938449113d9805) 

8)ドメインコントローラ - Windows Active Directory
9)keytabでプリンシパルを認証するためにkinitコマンドを実行しようとすると、同じエラーが発生する)

Command - kinit -k -t xyztest.keytab HTTP/[email protected] 
Result - Exception krb_error 6 client not found in kerberos database (6) 

10)HelloKDC.java:リンクhttp://spnego.sourceforge.net/はKDCへの接続をテストするためにHelloKDC.javaを提供します。私は正常にKerberosデータベースに見つからないエラー
クライアントを解決するために私にソリューションを提供してくださいHelloKDC.java

public final class HelloKDC { 

    private HelloKDC() { 
     // default private 
    } 

    public static void main(final String[] args) throws Exception { 

     // Domain (pre-authentication) account 
     final String username = "xyztest"; 

     // Password for the pre-auth acct. 
     final String password = "!Dragonfly1!"; 

     // Name of our krb5 config file 
     final String krbfile = "krb5.conf"; 

     // Name of our login config file 
     final String loginfile = "login.conf"; 

     // Name of our login module 
     final String module = "spnego-client"; 

     // set some system properties 
     System.setProperty("java.security.krb5.conf", krbfile); 
     System.setProperty("java.security.auth.login.config", loginfile); 
     //System.setProperty("sun.security.krb5.debug", true); 

     // assert 
     HelloKDC.validate(username, password, krbfile, loginfile, module); 

     final CallbackHandler handler = 
      HelloKDC.getUsernamePasswordHandler(username, password); 

     final LoginContext loginContext = new LoginContext(module, handler); 

     // attempt to login 
     loginContext.login(); 

     // output some info 
     System.out.println("Subject=" + loginContext.getSubject()); 

     // logout 
     loginContext.logout(); 

     System.out.println("Connection test successful."); 
    } 

    private static void validate(final String username, final String password 
     , final String krbfile, final String loginfile, final String moduleName) 
     throws FileNotFoundException, NoSuchAlgorithmException { 

     // confirm username was provided 
     if (null == username || username.isEmpty()) { 
      throw new IllegalArgumentException("Must provide a username"); 
     } 

     // confirm password was provided 
     if (null == password || password.isEmpty()) { 
      throw new IllegalArgumentException("Must provide a password"); 
     } 

     // confirm krb5.conf file exists 
     if (null == krbfile || krbfile.isEmpty()) { 
      throw new IllegalArgumentException("Must provide a krb5 file"); 
     } else { 
      final File file = new File(krbfile); 
      if (!file.exists()) { 
       throw new FileNotFoundException(krbfile); 
      } 
     } 

     // confirm loginfile 
     if (null == loginfile || loginfile.isEmpty()) { 
      throw new IllegalArgumentException("Must provide a login file"); 
     } else { 
      final File file = new File(loginfile); 
      if (!file.exists()) { 
       throw new FileNotFoundException(loginfile); 
      } 
     } 

     // confirm that runtime loaded the login file 
     final Configuration config = Configuration.getConfiguration(); 

     // confirm that the module name exists in the file 
     if (null == config.getAppConfigurationEntry(moduleName)) { 
      throw new IllegalArgumentException("The module name " 
        + moduleName + " was not found in the login file"); 
     }   
    } 

    private static CallbackHandler getUsernamePasswordHandler(
     final String username, final String password) { 

     final CallbackHandler handler = new CallbackHandler() { 
      public void handle(final Callback[] callback) { 
       for (int i=0; i<callback.length; i++) { 
        if (callback[i] instanceof NameCallback) { 
         final NameCallback nameCallback = (NameCallback) callback[i]; 
         nameCallback.setName(username); 
        } else if (callback[i] instanceof PasswordCallback) { 
         final PasswordCallback passCallback = (PasswordCallback) callback[i]; 
         passCallback.setPassword(password.toCharArray()); 
        } else { 
         System.err.println("Unsupported Callback: " 
           + callback[i].getClass().getName()); 
        } 
       } 
      } 
     }; 

     return handler; 
    } 
} 

でKDCに接続することができます(6)

klistを出力

#0>  Client: xyztest @ CORP.XYZ.COM 
     Server: krbtgt/CORP.XYZ.COM @ CORP.XYZ.COM 
     KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96 
     Ticket Flags 0x60a10000 -> forwardable forwarded renewable pre_authent n 
ame_canonicalize 
     Start Time: 3/8/2017 10:01:14 (local) 
     End Time: 3/8/2017 20:01:14 (local) 
     Renew Time: 3/15/2017 10:01:14 (local) 
     Session Key Type: AES-256-CTS-HMAC-SHA1-96 
     Cache Flags: 0x2 -> DELEGATION 
     Kdc Called: xyzDC1.corp.xyz.com 

#1>  Client: xyztest @ CORP.XYZ.COM 
     Server: krbtgt/CORP.XYZ.COM @ CORP.XYZ.COM 
     KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96 
     Ticket Flags 0x40e10000 -> forwardable renewable initial pre_authent nam 
e_canonicalize 
     Start Time: 3/8/2017 10:01:14 (local) 
     End Time: 3/8/2017 20:01:14 (local) 
     Renew Time: 3/15/2017 10:01:14 (local) 
     Session Key Type: AES-256-CTS-HMAC-SHA1-96 
     Cache Flags: 0x1 -> PRIMARY 
     Kdc Called: xyzDC1.corp.xyz.com 

#2>  Client: xyztest @ CORP.XYZ.COM 
     Server: ldap/xyzDC1.corp.xyz.com @ CORP.XYZ.COM 
     KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96 
     Ticket Flags 0x40a50000 -> forwardable renewable pre_authent ok_as_deleg 
ate name_canonicalize 
     Start Time: 3/8/2017 10:01:16 (local) 
     End Time: 3/8/2017 20:01:14 (local) 
     Renew Time: 3/15/2017 10:01:14 (local) 
     Session Key Type: AES-256-CTS-HMAC-SHA1-96 
     Cache Flags: 0 
     Kdc Called: xyzDC1.corp.xyz.com 

#3>  Client: xyztest @ CORP.XYZ.COM 
     Server: LDAP/xyzDC1.corp.xyz.com/corp.xyz.com @ CORP.ADAP 
TIVE.COM 
     KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96 
     Ticket Flags 0x40a50000 -> forwardable renewable pre_authent ok_as_deleg 
ate name_canonicalize 
     Start Time: 3/8/2017 10:01:15 (local) 
     End Time: 3/8/2017 20:01:14 (local) 
     Renew Time: 3/15/2017 10:01:14 (local) 
     Session Key Type: AES-256-CTS-HMAC-SHA1-96 
     Cache Flags: 0 
     Kdc Called: xyzDC1.corp.xyz.com 

#4>  Client: xyztest @ CORP.XYZ.COM 
     Server: cifs/xyzDC1.corp.xyz.com @ CORP.XYZ.COM 
     KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96 
     Ticket Flags 0x40a50000 -> forwardable renewable pre_authent ok_as_deleg 
ate name_canonicalize 
     Start Time: 3/8/2017 10:01:14 (local) 
     End Time: 3/8/2017 20:01:14 (local) 
     Renew Time: 3/15/2017 10:01:14 (local) 
     Session Key Type: AES-256-CTS-HMAC-SHA1-96 
     Cache Flags: 0 
     Kdc Called: xyzDC1.corp.xyz.com 
+0

Hi @ T-Heron助けてくれてありがとう。上記の提案では、Kerberosデータベースに存在しないクライアントは解決されています。ただし、klistを実行すると、サーバー/アプリケーション用に生成されたチケットは一覧表示されません。もう1つの質問 - ntlmまたはKerberosが認証に使用されているかどうかを特定する方法klistコマンドの出力で質問を編集しました。もう助けてください。 – Rupali

+0

サイトごとのガイドラインでは、特定の問題または質問に限定された質問を、適切な回答を特定し、複数の異なる質問を一度に尋ねるのではなく、この領域の詳細については、[質問]ページを参照してください。 Subject行とここでの中心的な問題は、「_Exception - クライアントがspnego-Kerberos IWA_を持つKerberosデータベース(6)に見つかりませんでした。それは答えられました。そして今、この質問は、広範な協議に変わりつつあり、それはこのサイトが設計されたものではありません。 –

答えて

1

Kerberos環境で作業する場合は、以下の点に注意してください。

  1. レルムを使用している場合でも、キータブファイルを作成する場合は、レルム(ドメイン名)を大文字にする必要があります。
  2. SPNEGO認証の場合、各サーバーホストはWeb認証ユーザーのHTTP /ホスト名としてマップする必要があります。例えば、

    ます。setspn -s HTTP /ホスト名xyztest

  3. Kerberosチケットは、ユーザー名とパスワード

    kinit principal password 
    
    を使用してKerberosチケットを取得するには、各操作のための環境KRB5CCNAMEで

利用可能であるべきです

キータブを使用してKerberosチケットを取得するには

kinit -k -t keytab principal 

あなたはチケットの詳細、Javaの\ビンに変更ディレクトリの一覧を表示し、klistを実行するには、環境変数KRB5CCNAME

set krb5ccname=newticketfilelocation 

を使用して、チケットの場所を設定することができます。これは、klistコマンドがウィンドウで使用可能で、ログインしたユーザーチケットのみを表示するためです。 kinitコマンドから取得したチケットを一覧表示するには、java \ binの場所から実行する必要があります。

+0

お返事ありがとうございます。私はjava/binからklistを実行し、次のエントリを見つけました。[1]サービスプリンシパル:krbtgt/[email protected] 有効開始:2017年3月7日10:02 有効期限:2017年3月7日20 :02 – Rupali

+0

もう1つの質問 - ntlmまたはKerberosがSPNEGO認証に使用されているかどうかを確認する方法 – Rupali

+0

これについてはわかりません。しかし、可能な方法は、間違った信任状を供給するときに例外から識別することです。 Gss Exceptionを取得した場合は、Kerberosでなければなりません。 このリンクを確認することができます。http://stackoverflow.com/a/18701355/3496666 – Kumar

関連する問題