We have installed Client and Personal certificates in our windows store and we have written .NET code to connect MQ server from MQ client. We are getting Reason Code 2393 but certificates are already present in windows store.

My .NET code is
using System;
using System.Net;
using System.Text.Json;
using IBM.XMS;
namespace IBMMQ;
/// <summary>
/// Runs IBM MQ tests: connection, send, receive, and round-trip.
/// </summary>
public class MqTestRunner
{
public IConnectionFactory CreateConnectionFactory(MqConfig config)
{
if (string.IsNullOrWhiteSpace(config.Channel))
throw new ArgumentException("Channel is required for MQ connection. Set 'Channel' in App.config or MQ_CHANNEL environment variable.", nameof(config));
var factoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
var cf = factoryFactory.CreateConnectionFactory();
cf.SetStringProperty(XMSC.WMQ_HOST_NAME, config.Host ?? "");
cf.SetIntProperty(XMSC.WMQ_PORT, config.Port);
cf.SetStringProperty(XMSC.WMQ_CHANNEL, config.Channel!.Trim());
cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, config.QueueManager ?? "");
cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
//if (!string.IsNullOrEmpty(config.UserId))
// cf.SetStringProperty(XMSC.USERID, config.UserId);
//if (!string.IsNullOrEmpty(config.Password))
// cf.SetStringProperty(XMSC.PASSWORD, config.Password);
// TLS with client certificate authentication (managed .NET client)
if (config.UseCertificateAuth)
{
// Key repository: *USER = current user cert store, *SYSTEM = local machine
// Client cert must be in "Personal (My)" store; CA cert in "Trusted Root"
cf.SetStringProperty(XMSC.WMQ_SSL_KEY_REPOSITORY, config.SslKeyRepository ?? "*USER");
// TLS CipherSpec (must match queue manager SVRCONN SSLCIPH - use WMQ_SSL_CIPHER_SPEC for WMQ channels)
cf.SetStringProperty(XMSC.WMQ_SSL_CIPHER_SPEC, config.SslCipherSuite ?? "TLS_RSA_WITH_AES_256_CBC_SHA256");
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13;
if (!string.IsNullOrWhiteSpace(config.SslPeerName))
{
// Optional: validate server cert (e.g. CN=QueueManagerName)
var peerName = config.SslPeerName!.Trim();
if (!peerName.StartsWith("CN=", StringComparison.OrdinalIgnoreCase))
peerName = "CN=" + peerName;
cf.SetStringProperty(XMSC.WMQ_SSL_PEER_NAME, peerName);
}
}
Console.WriteLine($"Host={config.Host}, Port={config.Port}, Channel={config.Channel}," +
$" QueueManager={config.QueueManager}, UseCertificateAuth={config.UseCertificateAuth}" +
$" SslKeyRepository={config.SslKeyRepository}, SslCipherSuite={config.SslCipherSuite}" +
$" SslPeerName={config.SslPeerName}");
Console.ReadLine();
return cf;
}
/// <summary>
/// Test 1: Verify connection to the queue manager.
/// </summary>
public bool TestConnection(MqConfig config, out string? error)
{
error = null;
try
{
Console.WriteLine("Connection test started.");
Console.ReadLine();
var cf = CreateConnectionFactory(config);
Console.WriteLine("Connection started after factory.");
Console.ReadLine();
Console.WriteLine($"Host={cf.GetStringProperty(XMSC.WMQ_HOST_NAME)}, Port={cf.GetIntProperty(XMSC.WMQ_PORT)}, Channel={cf.GetStringProperty(XMSC.WMQ_CHANNEL)}," +
$" QueueManager={cf.GetStringProperty(XMSC.WMQ_QUEUE_MANAGER)}, UseCertificateAuth={config.UseCertificateAuth}" +
$" SslKeyRepository={cf.GetStringProperty(XMSC.WMQ_SSL_KEY_REPOSITORY)}, SslCipherSuite={cf.GetStringProperty(XMSC.WMQ_SSL_CIPHER_SPEC)}" +
$" SslPeerName={cf.GetStringProperty(XMSC.WMQ_SSL_PEER_NAME)}");
using var connection = cf.CreateConnection();
connection.Start();
Console.WriteLine("Connection established...");
Console.ReadLine();
connection.Stop();
return true;
}
catch (XMSException ex)
{
error = ex.Message;
Console.WriteLine($"Connection test failed: {error}");
Console.WriteLine();
Console.WriteLine("--- Detailed exception trace ---");
Console.WriteLine(ex.ToString());
if (ex.InnerException != null)
{
Console.WriteLine("--- Inner exception ---");
Console.WriteLine(ex.InnerException.ToString());
}
Console.WriteLine("--------------------------------");
Console.ReadLine();
return false;
}
catch (Exception ex)
{
error = ex.Message;
Console.WriteLine($"Connection test failed (unexpected): {error}");
Console.WriteLine();
Console.WriteLine("--- Detailed exception trace ---");
Console.WriteLine(ex.ToString());
if (ex.InnerException != null)
{
Console.WriteLine("--- Inner exception ---");
Console.WriteLine(ex.InnerException.ToString());
}
Console.WriteLine("--------------------------------");
Console.ReadLine();
return false;
}
}
}
Request any suggestion If anyone get this same issue..