SSL不与IBM MQ 8客户端jar一起使用

时间:2016-07-11 13:08:26

标签: java ssl ibm-mq mq

SSL适用于IBM MQ 6客户端jar,但相同的代码不适用于IBM 8 jars。任何人都遇到IBM 8客户端jar问题。

代码:

            com.ibm.mq.MQQueueManager qmRequest = null;
            com.ibm.mq.MQQueue qRequest = null;

            com.ibm.mq.MQMessage reqMsg = new com.ibm.mq.MQMessage();
            reqMsg.writeString(new String("first MQ SSL Message test"));
            reqMsg.messageId = "1".getBytes();
            reqMsg.correlationId = "2".getBytes(); 



            System.setProperty("javax.net.ssl.trustStore", "D:/keystore/testKS.jks");
            System.setProperty("javax.net.ssl.trustStorePassword", "12345678");
            System.setProperty("javax.net.ssl.keyStore", "D:/keystore/testKS.jks"); 
            System.setProperty("javax.net.ssl.keyStorePassword", "12345678"); 
            Hashtable<String,Object> propMap = new Hashtable<String,Object>();

            propMap.put(MQConstants.HOST_NAME_PROPERTY, "localhost");
            propMap.put(MQConstants.PORT_PROPERTY,  1415);
            propMap.put(MQConstants.CHANNEL_PROPERTY, "testG");
            propMap.put(MQConstants.SSL_PEER_NAME_PROPERTY, "CN=ibmwebspheremqtestqu");

            String qmNameRequest = "testQu";
            String qNameRequest = "testQQ";
            propMap.put(MQConstants.SSL_CIPHER_SUITE_PROPERTY,  "TLS_RSA_WITH_AES_128_CBC_SHA");
            qmRequest = new com.ibm.mq.MQQueueManager(qmNameRequest,propMap);

            int reqQueueOpt = MQConstants.MQOO_OUTPUT | MQConstants.MQOO_SET_IDENTITY_CONTEXT;
            qRequest = qmRequest.accessQueue(qNameRequest, reqQueueOpt);
            reqMsg.messageType = MQConstants.MQMT_DATAGRAM;
            com.ibm.mq.MQPutMessageOptions reqMsgOpt = new com.ibm.mq.MQPutMessageOptions();
            reqMsgOpt.options = MQConstants.MQPMO_SET_IDENTITY_CONTEXT;

            qRequest.put(reqMsg, reqMsgOpt);
            qRequest.close();
            qmRequest.disconnect();

上面的代码适用于IBM jdks但是使用oracle jdk它总是失败并抛出与SSL相关的异常。

1 个答案:

答案 0 :(得分:0)

你读过这个:http://www-01.ibm.com/support/docview.wss?uid=swg1IV66840

您是否设置了JVM环境变量&#34; -Dcom.ibm.mq.cfg.useIBMCipherMappings = false&#34;如IBM支持文档中所述?