I managed to connect to my local queue with SSL using the code below. It is an unmanaged client. However, when I connect to a remote queue, I encounter an error
Password protection negotiation failed.
The channel 'Remote_Queue' could not be established because it failed to agree a password protection algorithm with the remote machine 'xx.xxx.xxx.xxx(5593)'. &P The channel did not start.
Check whether the PasswordProtection attribute in the Channels stanza of mqclient.ini prevents interoperability with the remote machine. Consider changing the PasswordProtection attribute. &P Alternatively, consider using SSL or TLS to protect passwords instead. You must use a non-null CipherSpec to protect passwords.
What do I need to look at here? Thanks.
using System.Collections;
using IBM.WMQ;
using System;
namespace MqClientUnmanaged
{
class Program
{
static void Main(string[] args)
{
var queueManagerName = "Remote_QM";
var hostName = "xx.xxx.xxx.xxx";
var channel = "Remote_Channel";
var queueName = "Remote_Queue";
var port = "5593";
var sslKeyRepository = @"C:\ProgramData\IBM\MQ\mqdev";
var cipherSpec = "ECDHE_RSA_AES_256_CBC_SHA384";
var certLabel = "mqdev";
Hashtable prop = new Hashtable();
prop.Add(MQC.HOST_NAME_PROPERTY, hostName);
prop.Add(MQC.PORT_PROPERTY, port);
prop.Add(MQC.CHANNEL_PROPERTY, channel);
prop.Add(MQC.CONNECT_OPTIONS_PROPERTY, MQC.MQCNO_RECONNECT);
prop.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);
prop.Add(MQC.SSL_CERT_STORE_PROPERTY, sslKeyRepository);
prop.Add(MQC.SSL_CIPHER_SPEC_PROPERTY, cipherSpec);
prop.Add(MQC.CERT_LABEL_PROPERTY, certLabel);
foreach (DictionaryEntry de in prop)
{
Console.WriteLine("Key: {0}, Value: {1}", de.Key, de.Value);
}
try
{
var queueManager = new MQQueueManager(queueManagerName, prop);
MQQueue _queue = queueManager.AccessQueue(queueName, MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
Console.WriteLine("Connected");
MQMessage retrievedMessage = new MQMessage();
MQGetMessageOptions gmo = new MQGetMessageOptions();
_queue.Get(retrievedMessage, gmo);
Console.WriteLine("The message is: {0}", retrievedMessage.ReadString(retrievedMessage.MessageLength));
Console.WriteLine(new string('*', 100));
}
catch (MQException ex)
{
Console.WriteLine("An IBM MQ error occurred: {0}, {1}", ex.Message.ToString(), ex.StackTrace.ToString());
Console.ReadKey();
}
catch (System.Exception ex)
{
Console.WriteLine("A System error occurred: {0}, {1}", ex.Message.ToString(), ex.StackTrace.ToString());
Console.ReadKey();
}
Console.ReadKey();
}
}
}