我们需要使用 java 独立程序通过 SSL 连接到 MQ。我们已经从合作伙伴那里收到了 .arm
文件,并且我们已经使用 keytool
命令安装了证书,如下所示:
/opt/jdk1.8.0_121/bin/keytool -import -alias my_cert -file mycert.arm -keystore /opt/jdk1.8.0_121/jre/lib/security/cacerts
Enter keystore password:
---
---
----
Trust this certificate? [no]: yes
Certificate was added to keystore
在java中连接队列管理器的程序
MQEnvironment.hostname = "XX.XX.XX.XX";
MQEnvironment.channel = "Channel_Name"; // With SSL
MQEnvironment.port = XXXX;
System.setProperty("javax.net.debug", "ssl");
System.setProperty("javax.net.ssl.trustStore", "/opt/jdk1.8.0_121/jre/lib/security/cacerts");
System.setProperty("javax.net.ssl.trustStorePassword", "trustpass");
MQEnvironment.sslCipherSuite = "SSL_RSA_WITH_RC4_128_SHA";
_queueManager = new MQQueueManager("QueueManagerName");
System.out.println("\t _queueManager : " + _queueManager);
错误如下所示
keyStore type is : jks
keyStore provider is :
init keystore
init keymanager of type SunX509
MQJE001: An MQException occurred: Completion Code 2, Reason 2059
MQJE013: Error accessing socket streams
MQJE001: An MQException occurred: Completion Code 2, Reason 2059
MQJE013: Error accessing socket streams
Exception in thread "main" com.ibm.mq.MQException: MQJE001: An MQException occurred: Completion Code 2, Reason 2059
MQJE013: Error accessing socket streams
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:212)
能否请您帮助我们解决这个问题。
最佳答案
根据 this thread 原因 2059 与未运行的监听器服务有关。
Figured out the problem. There is a "HTTP SSL" service, which apparently needs to be running. When the box was rebooted, it wasn't started. Starting the service, and re-starting the WAS server fixed the problem.
关于java - 使用 Java 通过 SSL 连接 MQ7.X,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43002195/