2011-12-16 36 views
5

我有我的JMX服務器,它註冊從本地文件讀取的bean,並根據需要使其可供其他JMX客戶端使用。 可以使用「jconsole」或運行在Tomcat容器下的Java應用程序訪問服務器。支持在Java 6上運行的JMX客戶端/服務器上的Kerberos身份驗證/授權

我想要的是添加驗證,以防止「未知」身份訪問JMX服務器。要做到這一點我一直在使用添加Kerberos身份驗證服務器@以下JVM選項

-Dcom.sun.management.jmxremote=true 
-Dcom.sun.management.jmxremote.port=5555 
-Dcom.sun.management.jmxremote.authenticate=true 
-Dcom.sun.management.jmxremote.ssl=false 
-Djava.security.auth.login.config=./conf/jaas.conf 
-Djava.security.krb5.conf=./conf/krb5.conf 
-Dcom.sun.management.jmxremote.login.config=MyKrbAuth 
-Ddynamic.mbean.store=./conf/mbeans 
-Djava.net.preferIPv4Stack=true 

我的Jaas.conf看起來像這樣>>

MyKrbAuth { 
com.sun.security.auth.module.Krb5LoginModule required debug=true debugNative=true; 
}; 

當我開始我的JMX服務器與上面的配置,並嘗試連接它使用「JConsole的」,我得到的客戶端和連接下面的異常失敗>>

Cipher: Crypto Permission check failed 
Cipher: granted: (CryptoPermission * 128) 
Cipher: requesting: (CryptoPermission AES 256) 

但在服務器認證似乎是成功>>

[java] [STARTED] Mbean Server 
[java] Debug is true storeKey false useTicketCache false useKeyTab false doNotPrompt false ticketCache is null isInitiator true KeyTab is null refreshKrb5Config is false principal is null tryFirstPass is false useFirstPass is false storePass is false clearPass is false 
[java] [Krb5LoginModule] user entered username: username 
[java] 
[java] Acquire TGT using AS Exchange 
[java] principal is [email protected] 
[java] EncryptionKey: keyType=3 keyBytes (hex dump)=0000: FD 46 7C 02 19 9B 34 E9 
[java] EncryptionKey: keyType=1 keyBytes (hex dump)=0000: FD 46 7C 02 19 9B 34 E9 
[java] EncryptionKey: keyType=23 keyBytes (hex dump)=0000: FE 6D 82 01 8A D7 AB 60 98 
[java] EncryptionKey: keyType=16 keyBytes (hex dump)=0000: 89 02 31 5D F7 5B 3E 89 BC F7 8A 01 A1 80 C7 
[java] EncryptionKey: keyType=17 keyBytes (hex dump)=0000: A5 67 71 17 F6 57 A9 26 01 09 B1 EB 75 46 6C 
[java] 
[java] Commit Succeeded 
[java] 

從上面看來,客戶端無法解碼響應(這是AES256加密)..如何解決它?

回答

3

管理以解決上述問題。 這裏是你的JMX客戶機/服務器介紹Kerberos身份驗證/授權步驟

若要啓用Kerberos @ JMX服務器,

  1. 與下面的一組ARGS =>

    -Dcom.sun.management.jmxremote=true 
    -Dcom.sun.management.jmxremote.port=<port_no> 
    -Dcom.sun.management.jmxremote.authenticate=true 
    -Dcom.sun.management.jmxremote.ssl=false 
    -Djava.security.auth.login.config=<locatin_of_jaas.conf> 
    -Djava.security.krb5.conf=<locatin_of_krb5.conf> 
    -Dcom.sun.management.jmxremote.login.config=<name_of_login_config_to_be_used> 
    -Djava.net.preferIPv4Stack=true 
    
  2. 開始服務器
  3. 在$ JAVA_HOME/jre/lib/management/jmxremote.access中添加訪問條目。一旦用戶獲得認證,將根據jmxremote.access提供對JMX服務器的讀/寫訪問權限。可以使用在服務器以下JVM ARG啓動

    -Dcom.sun.management.jmxremote.access.file=<acees_control_file>  
    

若要啓用Kerberos @ JMX客戶端(JConsole的)

  1. 來啓動JConsole與調試選項&連接來提供。訪問文件的位置服務器

    jconsole -J-Djava.security.debug=all 
    
  2. 如果請求的加密是AES256,則下載ad unlimited strength cryptography policy jar files,提取並將策略文件放置在$ JAVA_HOME/jre/lib/security /下。 [感謝Mark指出政策包含。]

以上應的Kerberos工作在兩個JMX客戶端和JMX服務器端

如果你仍然在連接面臨的問題,那麼您可以使用logging.properties啓用JConsole的詳細調試文件=>

handlers = java.util.logging.ConsoleHandler 
.level = INFO 
java.util.logging.ConsoleHandler.level = FINEST 
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter 
// Use FINER or FINEST for javax.management.remote.level - FINEST is very verbose... 
javax.management.level = FINEST 
javax.management.remote.level = FINER 

並開始JConsole的使用

jconsole -J-Djava.util.logging.config.file=<location_of_logging.properties> 
+0

您添加到`jmxremote.access`的訪問條目是什麼?閱讀該文件中的文檔,它用於基於角色的訪問控制。 – Adam 2018-01-10 15:27:05

+0

多年後,我知道,但是您是否嘗試使用login.config`authzIdentity`元素來指定`jmxremote.access`角色,而不是將用戶名添加到文件中? – Adam 2018-01-10 17:11:55

3

您需要在Java安裝中包含unlimited strength cryptography policy file(鏈接用於Java 6,其他用戶請參閱java.oracle.com)。默認情況下,Java不允許使用像AES256這樣的高度加密(因爲美國的荒謬的出口法律認爲加密是武器/彈藥)。該策略文件將解鎖更強大的加密。

+0

感謝您的快速回復。安裝無限強度加密策略文件確實會隱藏異常。但joconsole仍然顯示「無法連接」。將調試更多,並將儘快更新 – 2011-12-16 14:11:24

0

我已經followe d上述說明並設法讓Kerberos認證工作,只要我在jconsole中輸入我的用戶名和密碼。不可避免地,這會通過明文形式發送我的密碼,因爲我在服務器上設置了com.sun.management.jmxremote.ssl = false。

您是否設法通過在客戶端使用緩存票證來連接jconsole?例如,如果你這樣做:

kinit user 
Password for [email protected]: 
New ticket is stored in cache file C:\Users\user\krb5cc_user 

然後嘗試連接jconsole到服務器,而不輸入您的用戶名/密碼?

相關問題