使用XMS.NET通过证书SSL连接IBM MQ时遭遇2059(MQRC_Q_MGR_NOT_AVAILABLE)错误的求助
XMS.NET通过证书SSL连接IBM MQ时遭遇2059(MQRC_Q_MGR_NOT_AVAILABLE)错误的求助
大家好,我最近在做一个.NET应用,需要用IBM.XMS(XMS.NET)客户端通过SSL连接IBM MQ队列管理器。我已经把客户端证书(.crt文件)导入到Windows证书存储的受信任的根证书颁发机构里了,但不管怎么试,一直碰到这个错误:
MQException: 2059 - MQRC_Q_MGR_NOT_AVAILABLE
我把自己的代码贴出来,麻烦各位帮忙看看哪里可能出问题了:
using IBM.XMS; using System; class Program { static void Main() { try { Console.WriteLine("Setting environment variable MQSSLKEYR..."); // Environment.SetEnvironmentVariable("MQSSLKEYR", @"C:\Users\ShivamK\Desktop\Dev\AA_Certificates\dev\dev\keystore"); // Without extension Console.WriteLine("Creating XMS Factory..."); XMSFactoryFactory factoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ); IConnectionFactory connectionFactory = factoryFactory.CreateConnectionFactory(); // Connection properties connectionFactory.SetStringProperty(XMSC.WMQ_HOST_NAME, "xxx.xx.com"); connectionFactory.SetIntProperty(XMSC.WMQ_PORT, 1444); connectionFactory.SetStringProperty(XMSC.WMQ_CHANNEL, "ABCD.01"); connectionFactory.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT); connectionFactory.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, "EMMMQQ"); // SSL connectionFactory.SetStringProperty(XMSC.WMQ_SSL_CIPHER_SPEC, "TLS_RSA_WITH_AES_128_CBC_SHA256"); // Auth connectionFactory.SetStringProperty(XMSC.USERID, "S10147878"); connectionFactory.SetStringProperty(XMSC.PASSWORD, "B7hkhkjk"); Console.WriteLine("Creating Connection..."); using IConnection connection = connectionFactory.CreateConnection(); using ISession session = connection.CreateSession(false, AcknowledgeMode.AutoAcknowledge); IDestination destination = session.CreateQueue("queue:///CGOOPSHDLG.XYZ.OPSDATA.01"); using IMessageConsumer consumer = session.CreateConsumer(destination); connection.Start(); Console.WriteLine("Waiting for a message..."); IMessage message = consumer.Receive(10000); // wait for 10s if (message is ITextMessage textMessage) Console.WriteLine($"Received message: {textMessage.Text}"); else Console.WriteLine("No message received or message not text."); connection.Stop(); } catch (XMSException ex) { Console.WriteLine("XMS Exception: " + ex.Message); if (ex.LinkedException != null) Console.WriteLine("Linked Exception: " + ex.LinkedException.Message); } catch (Exception ex) { Console.WriteLine("General Exception: " + ex.Message); } } }
我自己排查过的点:
- 确认了主机名、端口、通道名称、队列管理器名称这些配置都是和MQ管理员给的一致的
- 尝试过开启/关闭
MQSSLKEYR环境变量的设置(路径指向的是没有后缀的keystore文件) - 证书确实已经导入到Windows的受信任根证书存储里了
有没有大佬能指点一下,这个2059错误到底是哪里出问题了?是不是SSL证书的配置还有什么遗漏的地方?
内容来源于stack exchange
相关产品推荐
相关产品推荐

