我们创建了一个java swing项目来连接IBM MQ(安全和非安全)。我们正在使用RAD(IBM的V8.5库),安全和非安全的MQ连接在这个项目中运行良好。但是,当我们创建一个可执行jar文件,捆绑所有必需的IBM jar文件和SSL证书并运行它时,安全连接不起作用(使用可执行jar时非安全工作正常)。
public MQQueueManager mqConnect(String Qmanager, String hostname, String channel, int port) throws Exception {
Hashtable<String, SSLSocketFactory> props = null;
try {
props = setSSLKeystore("dev-cert.jks", "Password");
MQEnvironment.hostname = hostname;
MQEnvironment.channel = channel;
MQEnvironment.port = port;
if(channel.equals(SECURE_CHANNEL)){
MQEnvironment.sslCipherSuite="TLS_RSA_WITH_AES_128_CBC_SHA";
}else{
MQEnvironment.sslCipherSuite="";
}
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);
MQQueueManager mqQueueManager = (props != null) ? new MQQueueManager(Qmanager, props) : new MQQueueManager(Qmanager);
return mqQueueManager;
}catch (MQException mqExp) {
mqExp.printStackTrace();
return null;
}
}
private Hashtable<String, SSLSocketFactory> setSSLKeystore(String fileName, String password){
Hashtable<String, SSLSocketFactory> props = new Hashtable<String, SSLSocketFactory>();
try{
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(new FileInputStream(fileName), password.toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(ks, password.toCharArray());
KeyStore ts = KeyStore.getInstance("JKS");
ts.load(new FileInputStream(fileName), password.toCharArray());
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(ts);
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
props.put(MQC.SSL_SOCKET_FACTORY_PROPERTY, sslContext.getSocketFactory());
return props;
}catch(Exception e){
e.printStackTrace();return null;
}
}
我需要知道这里可能存在什么问题。这是例外。
com.ibm.mq.MQException: MQJE001: An MQException occurred: Completion Code 2, Reason 2009
MQJE016: MQ queue manager closed channel immediately during connect
Closure reason = 2009
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:276)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnection(MQClientManagedConnectionFactoryJ11.java:301)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection(MQClientManagedConnectionFactoryJ11.java:323)
at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:84)
at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:173)
at com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager(MQQueueManagerFactory.java:795)
at com.ibm.mq.MQQueueManagerFactory.procure(MQQueueManagerFactory.java:709)
at com.ibm.mq.MQQueueManagerFactory.constructQueueManager(MQQueueManagerFactory.java:664)
at com.ibm.mq.MQQueueManagerFactory.createQueueManager(MQQueueManagerFactory.java:160)
at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:554)
at com.mqutility.util.QueueOperations.mqConnect(QueueOperations.java:149)
at com.mqutility.main.QueueEditor$1.actionPerformed(QueueEditor.java:158)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:720)
at java.awt.EventQueue$4.run(EventQueue.java:718)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:717)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: com.ibm.mqservices.MQInternalException: MQJE001: An MQException occurred: Completion Code 2, Reason 2009
MQJE016: MQ queue manager closed channel immediately during connect
Closure reason = 2009
at com.ibm.mq.MQv6InternalCommunications.checkControlFlags(MQv6InternalCommunications.java:769)
at com.ibm.mq.MQv6InternalCommunications.establishChannel(MQv6InternalCommunications.java:665)
at com.ibm.mq.MQv6InternalCommunications.initialize(MQv6InternalCommunications.java:218)
at com.ibm.mq.MQv6InternalCommunications.<init>(MQv6InternalCommunications.java:111)
at com.ibm.mq.MQSESSIONClient.MQCONNX(MQSESSIONClient.java:1458)
at com.ibm.mq.MQSESSIONClient.MQCONN(MQSESSIONClient.java:1369)
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:252)