【问题标题】:No appropriate protocol (protocol is disabled or cipher suites are inappropriate)没有合适的协议(协议被禁用或密码套件不合适)
【发布时间】:2020-06-24 12:51:32
【问题描述】:

我正在尝试创建与启用了 ssl 身份验证的 mq 管理器的连接。我正在使用 Java 1.8

我有这个代码

TrustStrategy trustStrategy = new TrustSelfSignedStrategy();
KeyStore trustStore = KeyStore.getInstance("JKS");
try (FileInputStream fileInputStream = new FileInputStream(propertyReader.getProperty(QUEUE_KEYSTORE))) {
trustStore.load(fileInputStream, propertyReader.getProperty(QUEUE_KEYSTOREPASS).toCharArray());
}
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(trustStore, "changeit".toCharArray());
final TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(trustStore);

final SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new SecureRandom());

connectionFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
connectionFactory.setHostName(propertyReader.getProperty(QUEUE_HOST));
connectionFactory.setQueueManager(propertyReader.getProperty(QUEUE_MANAGER));
connectionFactory.setChannel(propertyReader.getProperty(QUEUE_CHANNEL));
connectionFactory.setSSLCipherSuite(propertyReader.getProperty(QUEUE_CIPHERSUITE));
connectionFactory.setPort(Integer.parseInt(propertyReader.getProperty(QUEUE_PORT)));
connectionFactory.setSSLSocketFactory(sslContext.getSocketFactory());

当我尝试创建连接时,我得到了这个异常

com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2397
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

我可以在日志中看到以下内容:

Allow unsafe renegotiation: false
Allow legacy hello messages: true
Is initial handshake: true
Is secure renegotiation: false
Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA256 for TLSv1
No available cipher suite for TLSv1
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
[Raw write]: length = 7
0000: 15 03 03 00 02 02 28                               ......(
called closeSocket()

这是说它仍在尝试使用 TLSv1 而不是 TLCv1.2? 我的安全文件中启用了 jce 无限强度。

更新细节:

IBM MQ Jar 版本:6.0.2.5

java 版本“1.8.0_201”

Java(TM) SE 运行时环境(内部版本 1.8.0_201-b26)

【问题讨论】:

  • 需要更多信息。您使用的是什么版本的 IBM MQ jar 文件,请检查 com.ibm.mq*.jar 文件中的 MANIFEST.MF。您使用的是什么特定的 java 版本,请提供 java - version 的输出。请编辑问题并添加这些详细信息。
  • 我已用所要求的详细信息更新了问题。
  • 这让我大吃一惊:Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA256 for TLSv1。请参阅stackoverflow.com/questions/33089150/…您要连接到运行的服务器是什么?
  • V6 不支持 tlsv1.2。自 2012 年以来,它也不再受支持。升级到 9.1,它甚至在 Maven 上。
  • 如果您想使用 TLS1.2 密码套件,您需要移动到支持它的 jar 文件版本。

标签: java ssl ibm-mq


【解决方案1】:

您已声明您正在使用来自 v6.0.2.5 的 IBM MQ jar 文件,这在 2012 年 9 月 30 日失去了 IBM 的支持。有关该旧版本支持的唯一 CipherSuites 的更多详细信息,请参阅此问题的结尾版本。


您可以通过以下链接使用 Maven 获取当前的 IBM MQ v9.1.0.4 LTS 支持客户端:

MVN REPOSITORY » com.ibm.mq com.ibm.mq.allclient


我检查了保存为 PDF 和 MQ v6 的旧文档仅支持 SSL 和 TLS1.0 密码,列表如下:

SSL_RSA_WITH_NULL_MD5
SSL_RSA_WITH_NULL_SHA
SSL_RSA_EXPORT_WITH_RC4_40_MD5
SSL_RSA_WITH_RC4_128_MD5
SSL_RSA_WITH_RC4_128_SHA
SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5
SSL_RSA_WITH_DES_CBC_SHA
SSL_RSA_EXPORT1024_WITH_RC4_56_SHA
SSL_RSA_EXPORT1024_WITH_DES_CBC_SHA
SSL_RSA_WITH_3DES_EDE_CBC_SHA
SSL_RSA_WITH_AES_128_CBC_SHA
SSL_RSA_WITH_AES_256_CBC_SHA
SSL_RSA_WITH_DES_CBC_SHA
SSL_RSA_WITH_3DES_EDE_CBC_SHA
SSL_RSA_FIPS_WITH_DES_CBC_SHA
SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA

【讨论】:

    【解决方案2】:

    在花费大量时间搜索解决方案后,我在 open jdk 1.8 中遇到了同样的问题,我通过从 java.security 文件更改以下属性解决了这个问题。

    security.overridePropertiesFile=false
    

    如果你的情况是true,则将此属性更改为false

    【讨论】:

    • 问题在于 IBM MQ 库版本而不是 java.security 设置。
    猜你喜欢
    • 2021-08-05
    • 1970-01-01
    • 2021-11-30
    • 2021-08-26
    • 2021-05-02
    • 2021-09-27
    • 1970-01-01
    • 1970-01-01
    • 2016-10-27
    相关资源
    最近更新 更多