使用java通过SSL连接MQ7.X

时间:2017-03-24 14:32:50

标签: java ssl ibm-mq

我们需要使用java独立程序连接到MQ over SSL。我们收到了合作伙伴的.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)

请帮助我们解决此问题。

1 个答案:

答案 0 :(得分:0)

根据this thread 原因2059 与未运行的侦听器服务有关。

  

找出问题所在。有一个“HTTP SSL”服务,显然需要运行。重新启动该框时,它未启动。启动服务,并重新启动WAS服务器修复了问题。