Java 连接到 MQ 8

Java connection to WMQ 8

我正在尝试让现有的 Java 应用程序连接到 WebSphere MQ 8。这在过去与其他版本的 Java 和 WMQ 一起工作,但与 Java 8和 WMQ8,这不起作用。 我得到:

handling exception: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
SEND TLSv1.2 ALERT:  fatal, description = handshake_failure
WRITE: TLSv1.2 Alert, length = 2
called closeSocket()
Exception in thread "main" com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2397'.

我只是不明白为什么会这样。我已经设置了各种 javax.net.ssl 参数。我使用我创建的适当的 SSL_TRUSTSTORE & KEYSTORE。有一个SSL_CIPHERSUITE.

我已经(几乎)尝试了 WMQ 支持的所有已记录的密码套件;我正在处理整个列表,设置和环境如下:

  1. JAVA SSL_CIPHERSUITE = SSL_RSA_WITH_AES_256_CBC_SHA
  2. WMQ 频道 SSL_CIPHERSUITE = TLS_RSA_WITH_AES_256_CBC_SHA
  3. MQ 客户端 7.0.0.1 -- 我已经尝试切换到 MQ 客户端 8,但没有任何改进
  4. IBM WebSphere MQ,版本:8.0.0.5
  5. AMQERR01.log 中没有对应客户端错误
  6. Oracle Java 8 (Java(TM) SE Runtime Environment (build 1.8.0_60-b27)) -- 启用 SSLv3(更改 jdk.tls.disabledAlgorithms=RC4, DH 密钥大小 < 768)

附加信息:

你读过这个页面吗: https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_8.0.0/com.ibm.mq.dev.doc/q113220_.htm

您使用的是已弃用的 CipherSuite 吗?

MQ v7.0 于 2008 年 6 月 27 日发布(Fix Pack 7.0.0.1 于 2009 年 1 月 20 日发布)并自 2015 年 9 月 30 日(超过 1.5 年)起不再支持。根据我在下面的回答,此版本的 MQ 将不支持 Oracle JRE 上的 TLS CipherSuites,而您可以更新到更高版本的 Fix Pack 我强烈建议您移动到受支持的 MQ 客户端版本。较新的 MQ 客户端版本可以连接到较旧的 MQ 队列管理器。您可以在下面的 links 下载 java 仅安装的 MQ 8.0 或 MQ 9.0 jar 文件:


APAR IV66840 添加了新功能以允许非 IBM Java 运行time 环境的用户使用 TLS CipherSuites。

对于 v7.0,它包含在 Fix Pack 7.0.1.13 中(请注意,Fix Pack 7.0.1.14 是此版本的最终版本)。

对于 8.0,这包含在 Fix Pack 8.0.0.2 中。

注意:此 APAR 是客户端修复。

要启用此选项,您需要执行以下操作:

To enable these non-default mappings for non-IBM runtime environments, the following Java System Property:

com.ibm.mq.cfg.useIBMCipherMappings

must be set to the value:

false

For example, this can be configured by using the JVM argument:

-Dcom.ibm.mq.cfg.useIBMCipherMappings=false

然后您需要将 CipherSuite 指定为 Oracle JRE 的 TLS_RSA_WITH_AES_256_CBC_SHA,请注意 SSL_RSA_WITH_AES_256_CBC_SHA 是 IBM JRE CipherSuite 名称。


通过上述步骤后,您可能会 运行 收到 AMQ9771、2393 SSL 初始化错误。

dW 回答 post“Why do I get AMQ9771, 2393 SSL Initialization error from a MQ Java/JMS application when trying to use an TLS AES 256 cipher?”。它指出以下内容:

In this case, the issue is caused by attempting to use AES 256 strong cipher algorithms.

Most Java JREs, including Oracle/Sun and IBM's have Import Limits on Cryptographic Algorithms enabled. This limits the maximum key sizes and also some algorithms.

When trying to use a AES 256 cipher, such as ECDHE_RSA_AES_256_CBC_SHA384 or TLS_RSA_WITH_AES_256_CBC_SHA256 with a MQ Java/JMS application, you need to ensure your JRE supports this cipher. In most cases, when the stronger cipher algorithms are needed, such as AES 256 ciphers, the JCE Unlimited Strength Jurisdiction Policy Files must be obtained and installed in the JDK/JRE.

This is noted in the JDK/JRE documentation: For Oracle 1.7:

http://docs.oracle.com/javase/7/docs/technotes/guides/security/SunProviders.html

oracle 站点上面的 link 状态:

If stronger algorithms are needed (for example, AES with 256-bit keys), the JCE Unlimited Strength Jurisdiction Policy Files must be obtained and installed in the JDK/JRE.

It is the user's responsibility to verify that this action is permissible under local regulations.

如果您确实获得了 2393,请按照上面的建议获取并安装 JCE Unlimited Strength Jurisdiction 策略文件.