MQRC_KEY_REPOSITORY_ERROR with IBMXMSDotnetClient 9.3 and .net 6

78 Views Asked by At

I am trying to connect to a remote IBM MQ manager from Windows server using a .net 6 console application and IBMXMSDotnetClient 9.3.4.1.

I am able to connect using the command prompt. The following is what I did:

  1. My MQCHLLIB path is C:\MQLib and contains the follow files:
  • keyrepo.kdb - contains pkcs12 and CA,
  • keyrepo.sth,
  • mqclient.ini,
  • ccdt.json - contains the channel information etc., cipherSpecification is ANY_TLS13_OR_HIGHER
  1. I ran the follow commands from the MQCHLLIB folder to set the variables:
set MQCHLLIB=C:\MQLib  
set MQCHLTAB=ccdt.json  
set MQCLNTCF=C:\MQLib\mqclient.ini  
set MQSSLKEYR=C:\MQLib\keyrepo  
set MQCERTLABL=certlabel 
  1. Then I executed:
amqsputc queueName *queueManager  

The connection works and I am able to put a message.

This is a block C# code I've tried for creating the connection. The settings object has properties as outlined above:

IConnection connectionWMQ;
IConnectionFactory cf = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ).CreateConnectionFactory();
cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
cf.SetStringProperty(XMSC.WMQ_CCDTURL, ccdtURL);   /* file://c:\\MQLib\\ccdt.json */
cf.SetStringProperty(XMSC.WMQ_SSL_CIPHER_SPEC, "ANY_TLS13_OR_HIGHER");
cf.SetStringProperty(XMSC.WMQ_SSL_CLIENT_CERT_LABEL, settings.MQCERTLABL);
cf.SetStringProperty(XMSC.WMQ_SSL_KEY_REPOSITORY, settings.MQSSLKEYR);  //Also tried *USER, got 2393
cf.SetStringProperty(XMSC.WMQ_SSL_PEER_NAME, settings.MQCERTLABL);

using(connectionWMQ = cf.CreateConnection()){
    //...
}

I get the following error

CWSMQ0006E: An exception was received during the call to the method ConnectionFactory.CreateConnection: CompCode: 2, Reason: 2381. During execution of the specified method an exception was thrown by another component. See the linked exception for more information.

at IBM.XMS.Client.WMQ.Factories.WmqConnectionFactory.CreateProviderConnection(XmsPropertyContext connectionProps) at IBM.XMS.Client.Impl.XmsConnectionFactoryImpl.CreateConnection(String userID, String password) at IBM.XMS.Client.Impl.XmsConnectionFactoryImpl.CreateConnection()

I've also tried

Environment.SetEnvironmentVariable("MQCERTLABL", settings.MQCERTLABL);
Environment.SetEnvironmentVariable("MQCHLLIB", settings.MQCHLLIB);
Environment.SetEnvironmentVariable("MQCHLTAB", settings.MQCHLTAB);
Environment.SetEnvironmentVariable("MQCLNTCF", settings.MQCLNTCF);
Environment.SetEnvironmentVariable("MQSSLKEYR", settings.MQSSLKEYR);

Hashtable properties = new Hashtable();
properties.Add(MQC.HOST_NAME_PROPERTY, HOSTNAME);
properties.Add(MQC.PORT_PROPERTY, PORT);
properties.Add(MQC.CHANNEL_PROPERTY, CHANNEL);
properties.Add(MQC.SSL_CERT_STORE_PROPERTY, settings.MQSSLKEYR); // Also tried *USER, got 2393 error 
properties.Add(MQC.SSL_CIPHER_SPEC_PROPERTY, ANY_TLS13_OR_HIGHER);
properties.Add(MQC.SSL_PEER_NAME_PROPERTY, settings.MQCERTLABL);
properties.Add("CertificateLabel", settings.MQCERTLABL);
MQQueueManager qManager = new MQQueueManager(queueManagerName, properties);

I've looked here for guidance
Been at this for weeks and can't find a solution. Any help is greatly appreciated

0

There are 0 best solutions below