简体   繁体   English

使用匿名SSL连接到WebSphere MQ

[英]Connecting to WebSphere MQ using anonymous SSL

I get exception "com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2393'" in the below code. 我在下面的代码中收到异常"com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2393'" My requirement is to connect QM using a SSL server-connection channel. 我的要求是使用SSL服务器连接通道连接QM。 Client authentication is not required . 不需要客户端身份验证

import com.ibm.mq.*;
public class MQSeriesDataCollector implements CustomDCInf
{
public static void main (String [] args)
{
    String qName="apm_qm";
    MQEnvironment.hostname=args [0]; 
    MQEnvironment.channel=args [1]; 
    MQEnvironment.port=Integer.parseInt(args [2]);
    MQEnvironment.sslFipsRequired=true;
    MQEnvironment.sslCipherSuite = "SSL_RSA_WITH_RC4_128_MD5";//RC4_MD5_US
    MQQueueManager qMgr=null;
    try{
        qMgr = new MQQueueManager("apm_qm");
    }catch (MQException mqe){
        mqe.printStackTrace();
}
PCFMessageAgent agent=null;
StringBuffer output = new StringBuffer();
MQSeriesDataCollector mqTest=new MQSeriesDataCollector();
        try{
            agent = mqTest.getMQConnection(qMgr);
            output.append(mqTest.getQueueStats(agent));
        }
        catch(MQException mqe){
            System.out.println("Error:" + mqe.reasonCode + " Description:"+PCFConstants.lookupReasonCode (mqe.reasonCode));
            mqe.printStackTrace();
        }
        catch(NoClassDefFoundError ex){
            ex.printStackTrace();
        }
        catch (Exception e){            
             e.printStackTrace();           
        }
        finally{
            try{
                if(agent!=null){
                    agent.disconnect();
                }
            }            
            catch(Exception ex){                
                ex.printStackTrace();
            }
        }

        System.out.println(output.toString());
    }
Exception:
com.ibm.mq.MQException: MQJE001: Completion Code '2', Reason '2393'.
        at com.ibm.mq.MQManagedConnectionJ11.(MQManagedConnectionJ11.java:235)
        at com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnection(MQClientManagedConnectionFactoryJ11.java:505)
        at com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection(MQClientManagedConnectionFactoryJ11.java:547)

To meet your requirement of not authenticating the client side, the channel must be set to SSLCAUTH(OPTIONAL) . 为了满足您不对客户端进行身份验证的要求,必须将通道设置为SSLCAUTH(OPTIONAL) The queue manager must have a certificate and the client must have a trsuststore that contains the signer chain for the QMgr's cert (if CA signed) or the public key of the QMgr's cert (if self-signed). 队列管理器必须具有证书,并且客户端必须具有trsuststore,其中包含QMgr证书的签名者链(如果是CA签名)或QMgr证书的公钥(如果是自签名)。 Remember that with SSL/TLS the server side is always authenticated and that requires the personal certificate at the server and a way for the client to validate it. 请记住,使用SSL / TLS时,服务器端始终是经过身份验证的,这需要服务器上的个人证书以及客户端对其进行验证的方法。 Also, the client and QMgr must agree on the protocols used and if FIPS is required they must use one of the FIPS certified algorithms. 此外,客户和QMgr必须就所使用的协议达成共识,如果需要FIPS,则他们必须使用FIPS认证的算法之一。

There is one thing definitely wrong in the code posted above and several things that are secondary possible causes for the problem. 上面发布的代码中肯定有一件事是错误的,而有几件事是导致该问题的第二可能原因。 Once you resolve the config I'll described below, you may hit one of the secondary problems. 解决完我将在下面介绍的配置后,您可能会遇到第二个问题之一。 To be sure which of these applies, it would be necessary to know which version of WMQ client and server, channel definition, the SSL settings for the JSSE and/or command-line invocation, etc. 为了确定其中哪个适用,有必要知道WMQ客户端和服务器的版本,通道定义,JSSE的SSL设置和/或命令行调用等。

So in this case the 2393 indicates that the client side isn't able to initialize the SSL/TLS session. 因此,在这种情况下2393表示客户端无法初始化SSL / TLS会话。 The obvious problem is that, according to the Infocenter page SSL CipherSpecs and CipherSuites , these two settings are an invalid combination: 一个明显的问题是,根据信息中心页面SSL CipherSpecs和CipherSuites ,这两个设置是无效的组合:

MQEnvironment.sslFipsRequired=true;
MQEnvironment.sslCipherSuite = "SSL_RSA_WITH_RC4_128_MD5";//RC4_MD5_US

You didn't mention which version of WMQ client and server you are at so here's a link to that page for V7.0 , V7.1 and V7.5 . 您没有提到您使用的是哪个版本的WMQ客户端和服务器,因此这里有指向该页面的V7.0V7.1V7.5链接 Note that the column listing FIPS compliance does not include any MD5 Ciphersuite. 请注意,列出符合FIPS的列不包括任何MD5密码套件。 (MD5 is broken and should not be used for signing certs, SSL, TLS or much of anything else. For that matter, SSL is broken and only TLS ciphers should be used going forward but that's a discussion for another question.) To get this working you will either need to set MQEnvironment.sslFipsRequired=false or pick one of the ciphersuites that is certified and listed in the far right column. (MD5已损坏,不应用于对证书,SSL,TLS或其他任何东西进行签名。为此,SSL已损坏,并且以后仅应使用TLS密码,但这是另一个问题的讨论。)工作时,您将需要设置MQEnvironment.sslFipsRequired=false或选择经过认证并列在最右列的密码套件之一。

Not knowing the versions you are working with, I'd suggest setting FIPS to false and using NULL_SHA on the channel and SSL_RSA_WITH_NULL_SHA at the app until you are sure all the other configurations are working. 不知道你正在使用的版本,我建议设置FIPS以false和使用NULL_SHA通道和SSL_RSA_WITH_NULL_SHA的应用程序,直到你确信所有其他的配置工作。 This ciphersuite is available on all platforms at all versions of WMQ. 在所有版本的WMQ的所有平台上都可以使用此密码套件。 Using this to test with will insure all the other settings are correct. 使用此工具进行测试将确保所有其他设置正确。 Once you get it working, then pick a stronger ciphersuite based on TLS and SHA that is available on both the server and client side. 一旦工作,就可以基于服务器和客户端上可用的TLS和SHA选择更强大的密码套件。

That said, here are some of the other possible issues you may run into. 就是说,这是您可能遇到的其他一些可能的问题。

You can get a 2393 when the app doesn't find its truststore or the certificate or signer chain in that truststore which represents the server side. 当应用程序找不到代表服务器端的信任库或该信任库中的证书或签名者链时,您将获得2393。 You can pass these in on the command line: 您可以在命令行中传递这些:

java -Djavax.net.ssl.trustStore=key2.jks \
     -Djavax.net.ssl.trustStorePassword=passw0rd \
     -cp "%CLASSPATH%"  \
     com.ibm.examples.JMSDemo -pub -topic JMSDEMOPubTopic

The keystore and truststore operations are handled by the JSSE provider and not by WMQ itself. 密钥库和信任库操作由JSSE提供程序处理,而不是由WMQ本身处理。 So whichever method you usually use to configure the JSSE provider should work. 因此,通常使用哪种方法来配置JSSE提供程序都应该起作用。 In addition to command line as shown above, that might include container-managed settings in a Java EE server, for example. 除了上面显示的命令行外,例如,它可能还包括Java EE服务器中容器管理的设置。

You can also get an error (I don't recall if its 2393) if the connection gets as far as the server presenting its certificate and the truststore has the wrong or incomplete signer chain. 如果连接达到提供证书的服务器并且信任库的签名者链不正确或不完整,您也会收到错误消息(如果是2393,我将不记得了)。

Other possible causes for the 2393 include file permissions, misspellings of the path or file name, etc. 2393的其他可能原因包括文件许可权,路径或文件名的拼写错误等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM