【发布时间】: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 文件版本。