通过SSL从c#

时间:2018-07-24 09:33:12

标签: c# ssl websphere

我的公司有一个WebSphere SIB,我正尝试通过SSL通过c#与之连接。 通过使用XMS.NET,我的第一次尝试通过使用BootstrapBasicMessaging成功了。但是,转移到SSL时无法连接。 代码捕捉如下:

static void Main(string[] args)
{
    XMSFactoryFactory factoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WPM);
    IConnectionFactory cf = factoryFactory.CreateConnectionFactory();

    cf.SetStringProperty(XMSC.WPM_PROVIDER_ENDPOINTS, "192.168.3.22:22033:BootstrapTunneledSecureMessaging");
    cf.SetStringProperty(XMSC.WPM_TARGET_TRANSPORT_CHAIN, "InboundSecureMessaging");
    cf.SetStringProperty(XMSC.WPM_BUS_NAME, "DemandBus");
    //cf.setStringProperty(XMSC_WPM_SSL_KEY_REPOSITORY, "C:\\Program Files\\IBM\\gsk7\\bin\\XMSkey.kdb");
    //cf.setStringProperty(XMSC_WPM_SSL_KEYRING_STASH_FILE, "C:\\Program Files\\IBM\\gsk7\\bin\\XMSkey.sth");
    //cf.setStringProperty(XMSC_WPM_SSL_CIPHER_SUITE, "SSL_RSA_EXPORT_WITH_RC4_40_MD5");

    Console.WriteLine("Connection Factory created.");

    using (IConnection connection = cf.CreateConnection(null, null))
    {
        Console.WriteLine("Connection created.");
    }
}

我得到的异常是“ NotSupportException”,消息为“ XMSCS0042E:不支持使用SSL。\ r \ n已请求使用SSL协议进行连接,但此产品版本不支持此连接。 \ r \ n必须更改配置属性,以便不选择SSL。'

    at IBM.XMS.Comms.SSL.SecureSocket..ctor(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType, Hashtable cfgProps)
    at IBM.XMS.Comms.SocketFactory.CreateSecureSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType, Hashtable xmsCommsProps)
    at IBM.XMS.Comms.Channels.SecureSocketChannelFactory.MakeSecureSocket(ConnectionTarget target)
    at IBM.XMS.Comms.Channels.SecureSocketChannelFactory.CreateChannel()
    at IBM.XMS.Comms.Channels.HttpChannelFactory.CreateChannel()
    at IBM.XMS.Comms.Channels.HttpTunnelChannelFactory.CreateChannel()
    at IBM.XMS.Comms.ChannelFactory.CreateOutboundChannel(ConnectionTarget target, String localAddress)
    at IBM.XMS.SIB.JFAP.ClientConnectionTracker.MakeConnection(ConnectionTarget target, String localAddress)
    at IBM.XMS.SIB.JFAP.ClientConnectionTracker.Connect(IPEndPoint remoteHost, IConversationReceiveListener convRecvListener, TransportChain transportType, SICoreConnectionProperties siProps)
    at IBM.XMS.SIB.JFAP.ClientConversationFactory.Connect(EndPoint remoteHost, IConversationReceiveListener conversationReceiveListener, TransportChain transport, SICoreConnectionProperties siProps)
    at IBM.XMS.SIB.Comms.Client.ClientSideConnection.Connect(ConnectionProperties cp, IClientComponentHandshake cch, SICoreConnectionProperties siProps)
    at IBM.XMS.SIB.Trm.TrmSICoreConnectionFactoryImpl.Bootstrap(Credentials credentials, SICoreConnectionProperties connectionProperties, ClientAttachProperties cap)

然后,我将由IBM.XMS / SSL元素括起来的键值对添加到App.config中。该错误变为“找到模糊匹配”。

at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
at System.Type.GetMethod(String name)
at IBM.XMS.Comms.SocketWrapper..ctor(Socket s, Type socketClass)
at IBM.XMS.Comms.SocketFactory.CreateSecureSocket(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType, Hashtable xmsCommsProps)
at IBM.XMS.Comms.Channels.SecureSocketChannelFactory.MakeSecureSocket(ConnectionTarget target)
at IBM.XMS.Comms.Channels.SecureSocketChannelFactory.CreateChannel()
at IBM.XMS.Comms.Channels.HttpChannelFactory.CreateChannel()
at IBM.XMS.Comms.Channels.HttpTunnelChannelFactory.CreateChannel()
at IBM.XMS.Comms.ChannelFactory.CreateOutboundChannel(ConnectionTarget target, String localAddress)
at IBM.XMS.SIB.JFAP.ClientConnectionTracker.MakeConnection(ConnectionTarget target, String localAddress)
at IBM.XMS.SIB.JFAP.ClientConnectionTracker.Connect(IPEndPoint remoteHost, IConversationReceiveListener convRecvListener, TransportChain transportType, SICoreConnectionProperties siProps)
at IBM.XMS.SIB.JFAP.ClientConversationFactory.Connect(EndPoint remoteHost, IConversationReceiveListener conversationReceiveListener, TransportChain transport, SICoreConnectionProperties siProps)
at IBM.XMS.SIB.Comms.Client.ClientSideConnection.Connect(ConnectionProperties cp, IClientComponentHandshake cch, SICoreConnectionProperties siProps)
at IBM.XMS.SIB.Trm.TrmSICoreConnectionFactoryImpl.Bootstrap(Credentials credentials, SICoreConnectionProperties connectionProperties, ClientAttachProperties cap)

我完全被这个错误消息弄糊涂了。 我提供的代码足以重现此错误。因此,我省略了负责创建会话,目标和消息生产者的代码。

关于这个主题,我唯一能得到的文件就是这个文件,但是它对我来说不起作用。 https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_7.5.0/com.ibm.mq.msc.doc/xms_csecure_connfprp_wpm.htm

实际上,有许多资源通过IBM MQ.NET Client连接到IBM MQ。但是它不支持连接到WebSphere SIB。

有人可以帮助我找出我的错误吗? 预先感谢。

最诚挚的问候

0 个答案:

没有答案