使用SSL设置.Net IBM.XMS客户端 [英] Setting up .Net IBM.XMS client with SSL

查看:380
本文介绍了使用SSL设置.Net IBM.XMS客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须创建一个客户端来侦听队列中的消息.正在使用SSL,并且我正在点网中进行开发.我已经浏览了数百页的文档和论坛,以找到清晰明了的内容,但事实并非如此!

I have to create a client to listen to messages on a queue. SSL is being used and I am developing in dot net. I have trawled through hundreds of pages of documentation and forums to find something clear and concise and it looks like it just isn't like that!

我有一个jks,我可以通过telnet到正在发布队列的服务器.下面是我到目前为止的代码...

I have a jks, and I am able to telnet to the server where the queue is being published. Below is the code I have so far...

var factoryfactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
var connectionfactory = factoryfactory.CreateConnectionFactory();
connectionfactory.SetIntProperty(XMSC.WMQ_CONNECTION_MODE,XMSC.WMQ_CM_CLIENT_UNMANAGED);

connectionfactory.SetStringProperty(XMSC.WMQ_SSL_KEY_REPOSITORY, @"C:\...\spindev1.key");
connectionfactory.SetStringProperty(XMSC.WMQ_SSL_CIPHER_SPEC, "SHA_WITH_RSA");
connectionfactory.SetStringProperty(XMSC.WMQ_CHANNEL, "SPINDEV1");

var connection = connectionfactory.CreateConnection();

我认为某处必须有密码,但是我不知道怎么做.我当前的错误是2538.

I assume there must be a password somewhere but I cannot figure out how. My current error is 2538.

编辑

所以我刚刚添加了IP和端口,现在却收到错误代码2393.

So I just added IP and Port and now I'm getting error code 2393.

connectionfactory.SetStringProperty(XMSC.WMQ_HOST_NAME, "**.***.***.***");
connectionfactory.SetIntProperty(XMSC.WMQ_PORT, 1431);

编辑2

好吧,现在我设法开始使用提供队列数据的人员提供的代码,但是他说,要使用SSL密钥,必须以spindev1的身份运行该应用程序-当然,这意味着创建一个整个新帐户?

Okay so now I have managed to start using the code provided by the people who are providing the queue data, however he says that in order to use the SSL keys the application must be run as spindev1 - surely that would mean creating a whole new account?

推荐答案

现在可以解决问题.以下是创建和启动连接的代码摘录.主要问题之一是SSL密钥是为名为dev1的用户创建的,而我的用户是mcanty.如果我知道更多,我相信这个结果会早些.

Okay issues have now been resolved. Below is the extract of code which is creating and starting the connection. One of the main problems was the SSL keys were made for a user called dev1, whereas my user is mcanty. If I'd known more I'm sure this result would have come sooner.

    public SISMQConnection(string connectionFactoryName, string queueName, string sslPeerName,
        string bindingsFilePath, string sslKeyRepository)
    {
        try
        {
            Hashtable aHashtable = new Hashtable { { "XMSC_IC_URL", bindingsFilePath } };
            InitialContext jndi = new InitialContext(aHashtable);

            //Java Naming and Directory Interface (JNDI)
            _queueObject = (IDestination)jndi.Lookup(queueName);
            _queueManager = (IConnectionFactory)jndi.Lookup(connectionFactoryName);

            _queueManager.SetStringProperty(XMSC.WMQ_SSL_PEER_NAME, string.Format("CN=\"{0}\"", sslPeerName));
            _queueManager.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT_UNMANAGED);
            _queueManager.SetStringProperty(XMSC.WMQ_SSL_KEY_REPOSITORY, sslKeyRepository);
            _queueManager.SetStringProperty(XMSC.WMQ_SSL_CIPHER_SPEC, "DES_SHA_EXPORT");
        }
        catch (Exception e)
        {
        }
    }

    public void Connect()
    {
        try
        {
            IConnection QueueConnection = _queueManager.CreateConnection();

            QueueSession = QueueConnection.CreateSession(true, AcknowledgeMode.AutoAcknowledge);

            IMessageConsumer QueueConsumer = QueueSession.CreateConsumer(_queueObject);

            QueueConsumer.MessageListener = OnNewMessageCallback;

            QueueConnection.Start();
        }
        catch (Exception e)
        {
        }
    }

这篇关于使用SSL设置.Net IBM.XMS客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆