IBM MQ 在 SSL 握手时抛出 java.lang.UnsupportedOperationException

And*_*rew 3 java ssl jms ibm-mq

打电话时:

MQQueueConnectionFactory cf ...
cf.createConnection();
Run Code Online (Sandbox Code Playgroud)

com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.handshakeCompleted 方法开始:

public void handshakeCompleted(HandshakeCompletedEvent event) {
 X509Certificate[] peerCertificateChain = event.getPeerCertificateChain();
 ...
Run Code Online (Sandbox Code Playgroud)

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.");
}
Run Code Online (Sandbox Code Playgroud)

导致此异常:

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)
Run Code Online (Sandbox Code Playgroud)

该项目唯一的 IBM MQ 依赖项是:

com.ibm.mq:com.ibm.mq.allclient:9.2.0.0
Run Code Online (Sandbox Code Playgroud)

为什么 javax.net.ssl.getPeerCertificateChain() 调用该已弃用的方法?看起来问题出在 HandshakeCompletedEvent 类中,而不是 MQ 中。

编辑:此问题从 Java 15 开始。