【发布时间】:2021-01-11 09:16:01
【问题描述】:
调用时:
MQQueueConnectionFactory cf ...
cf.createConnection();
com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.handshakeCompleted 方法开始:
public void handshakeCompleted(HandshakeCompletedEvent event) {
X509Certificate[] peerCertificateChain = event.getPeerCertificateChain();
...
javax.net.ssl.SSLSession 中的getPeerCertificateChain:
default X509Certificate[] getPeerCertificateChain() throws SSLPeerUnverifiedException {
throw new UnsupportedOperationException("This method is deprecated and marked for removal. Use the getPeerCertificates() method instead.");
}
导致此异常:
Exception in thread "HandshakeCompletedNotify-Thread" java.lang.UnsupportedOperationException: This method is deprecated and marked for removal. Use the getPeerCertificates() method instead.
at java.base/javax.net.ssl.SSLSession.getPeerCertificateChain(SSLSession.java:295)
at java.base/javax.net.ssl.HandshakeCompletedEvent.getPeerCertificateChain(HandshakeCompletedEvent.java:173)
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.handshakeCompleted(RemoteTCPConnection.java:2448)
at java.base/sun.security.ssl.TransportContext$NotifyHandshake$1.run(TransportContext.java:685)
at java.base/sun.security.ssl.TransportContext$NotifyHandshake$1.run(TransportContext.java:682)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/sun.security.ssl.TransportContext$NotifyHandshake.run(TransportContext.java:682)
at java.base/java.lang.Thread.run(Thread.java:832)
项目唯一的 IBM MQ 依赖是:
com.ibm.mq:com.ibm.mq.allclient:9.2.0.0
为什么 javax.net.ssl.getPeerCertificateChain() 调用该已弃用的方法?看起来问题出在 HandshakeCompletedEvent 类中,而不是 MQ。
编辑:此问题始于 Java 15。
【问题讨论】:
-
您使用的是什么版本的 Java?
-
你试过开启ssl调试吗?您的信任库中有正确的证书吗?
-
我以为我一直在使用不同的 java 版本进行测试,但我不是因为 gradle 正在获取多个 org.gradle.java.home 设置。我现在看到这个问题从 Java 15 开始出现。我现在可以回到 14,但仍然......这是一个问题
-
不管怎样,库需要更新才能在更高版本的 Java 上运行的情况并不少见。 IBM 是否宣传
com.ibm.mq:com.ibm.mq.allclient:9.2.0.0应该适用于 Java 15? -
不,我没有看到任何来自 IBM 的 cmets,但我怀疑最终会发布更新。