有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

在Java 6上运行的JMX客户机/服务器上支持Kerberos身份验证/授权

我有我的JMX服务器,它注册从本地文件读取的bean,并根据需要将它们提供给其他JMX客户机。 可以使用“jconsole”或运行在Tomcat容器下的Java应用程序访问服务器

我想要的是添加身份验证,以防止“未知”身份访问JMX服务器。为了实现这一点,我使用以下JVM选项添加了Kerberos authentication@server

-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 user@localhost.com
[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) 个答案

  1. # 1 楼答案

    我已经按照上面的说明进行了操作,只要在jconsole中输入我的用户ID和密码,就可以成功地进行kerberos身份验证。不可避免地,当我设置com时,这会以明文形式通过网络发送我的密码。太阳经营jmxremote。服务器上的ssl=false

    您是否已通过在客户端使用缓存票证来连接jconsole?例如,如果您这样做了:

    kinit user
    Password for user@REALM:
    New ticket is stored in cache file C:\Users\user\krb5cc_user
    

    然后在没有输入用户ID/密码的情况下尝试将jconsole连接到服务器

  2. # 2 楼答案

    设法解决了上述问题。 以下是在JMX客户机/服务器上引入Kerberos身份验证/授权的步骤

    要启用Kerberos@JMX服务器

    1. 使用以下参数集启动服务器=>

      -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. 在$JAVA_HOME/jre/lib/management/jmxremote中添加访问条目。通道一旦用户获得身份验证,将基于jmxremote提供对JMX服务器的读/写访问。通道位置。在服务器启动时,可以使用以下jvm参数提供访问文件

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

    启用Kerberos@JMX客户端(jconsole)

    1. 使用调试选项启动jconsole&;连接到服务器

      jconsole -J-Djava.security.debug=all
      
    2. 如果请求的加密是AES256,则下载unlimited strength cryptography policy jar files,提取并将策略文件放在$JAVA_HOME/jre/lib/security/中。[感谢马克指出政策包容性。]

    以上内容应该使Kerberos在JMX客户端和JMX服务器端都能工作

    如果您仍然面临连接问题,那么可以使用日志记录为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 -J-Djava.util.logging.config.file=<location_of_logging.properties>
    
  3. # 3 楼答案

    您需要在Java安装中包含unlimited strength cryptography policy file(链接适用于Java 6,其他请参见java.oracle.com)。默认情况下,java不允许使用像AES256那样的强加密(因为美国的出口法律考虑了加密是武器/弹药)。策略文件将解锁更强的加密