![](/img/trans.png)
[英]Access Remote IBM MQ Server Queue using MQ Client through a java program
[英]Trying to access MQ 7.5 server through java client but getting error,has created SYSTEM.SSL.SVRCONN
没有SSL,我就可以连接,但是有了SSL,它会在MQ日志中抛出以下错误
AMQ9660: SSL key repository: password stash file absent or unusable.
EXPLANATION:
The SSL key repository cannot be used because MQ cannot obtain a password to
access it. Reasons giving rise to this error include:
(a) the key database file and password stash file are not present in the
location configured for the key repository,
(b) the key database file exists in the correct place but that no password
stash file has been created for it,
(c) the files are present in the correct place but the userid under which MQ is
running does not have permission to read them,
(d) one or both of the files are corrupt.
The channel is '????'; in some cases its name cannot be determined and so is
shown as '????'. The channel did not start.
ACTION:
Ensure that the key repository variable is set to where the key database file
is. Ensure that a password stash file has been associated with the key database
file in the same directory, and that the userid under which MQ is running has
read access to both files. If both are already present and readable in the
correct place, delete and recreate them. Restart the channel.
----- amqccisa.c : 5577 -------------------------------------------------------
6/30/2015 12:15:33 - Process(14120.5) User(locahost) Program(amqrmppa.exe)
Host(localhost) Installation(Installation1)
VRMF(7.5.0.2) QMgr(QM1)
AMQ9492: The TCP/IP responder program encountered an error.
这是产生错误的代码:
import javax.jms.JMSException;
import javax.jms.Session;
import com.ibm.mq.*;
import com.ibm.jms.JMSMessage;
import com.ibm.jms.JMSTextMessage;
import com.ibm.mq.jms.JMSC;
import com.ibm.mq.jms.MQQueue;
import com.ibm.mq.jms.MQQueueConnection;
import com.ibm.mq.jms.MQQueueConnectionFactory;
import com.ibm.mq.jms.MQQueueReceiver;
import com.ibm.mq.jms.MQQueueSender;
import com.ibm.mq.jms.MQQueueSession;
import java.io.*;
import javax.net.ssl.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.security.KeyStore;
/**
* simple testcase for Point-to-point messaging .
*/
public class MQTEST {
/**
* Main method
*
* @param args
*/
public static void main(String[] args) {
try {
SSLContext context = SSLContext.getDefault();
System.setProperty("javax.net.ssl.trustStore","D:\\IBM\\CERT\\truststore.jks");
System.setProperty("javax.net.ssl.keyStore","D:\\IBM\\Websphere\\Qmgrs\\QM1\\ssl\\key.kdb");
System.setProperty("javax.net.ssl.keyStorePassword","password");
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
// Config
cf.setHostName("localhost");
cf.setPort(1414);
cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
cf.setQueueManager("QM1");
cf.setChannel("SYSTEM.SSL.SVRCONN");
// cf.setChannel("SYSTEM.DEF.SVRCONN");
cf.setSSLCipherSuite("TLS_RSA_WITH_AES_128_CBC_SHA");
MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection();
MQQueueSession session = (MQQueueSession) connection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
MQQueue queue = (MQQueue) session.createQueue("queue:///LQ1");
MQQueueSender sender = (MQQueueSender) session.createSender(queue);
错误日志格式和问题的措辞表明,是队列管理器无法访问其KDB密钥库。
(注意:提供错误日志时,请告诉我们您是从QMgr还是从客户端获取的!“ MQ日志”可能会以任何一种方式出现。)
考虑到这一点,您应该执行设置过程来配置队列管理器的证书。 这包括:
如果这是用于CA签名的证书...
如果这是用于自签名证书...
如果省略了任何这些步骤,请从上次中断的地方继续。
如果忘记存储密码或存储文件已损坏,请使用iKeyman GUI或runmqakm
命令的相应选项重新创建密码。
请注意,如果完全不存在KDB,则QMgr仍会引发上述错误。 这是因为它所做的第一件事就是尝试打开隐藏文件。 如果找不到,则会抛出password stash file absent or unusable
错误。 即使没有创建KDB,也是如此。
队列管理器使用的密钥存储库的存储文件可能已损坏。 在这种情况下,我要做的是:
1)删除隐藏文件。
2)在IBM Key Management Utility中打开密钥库。
3)使用“ Key Database File/Stash Password
存储Key Database File/Stash Password
菜单再次创建一个新的存储文件。
然后尝试再次连接。
您的客户端应用程序代码使用javax.net.ssl.keyStore
.kdb
类型密钥存储库。 据我所知,MQ Java客户端将仅使用.jks
类型的密钥存储。 .kdb
类型的密钥库由队列管理器和非Java客户端(如C / C#)使用
HTH
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.