简体   繁体   English

使用JMS通过SSL连接到WebSphere MQ 7.0

[英]Connecting to WebSphere MQ 7.0 using JMS through SSL

I'm preparing a test environment to connect to Websphere MQ 7.0 through SSL, so I have to configure SSL on Websphere MQ myself before I start configuring the SSL connection from JMS side . 我正在准备一个通过SSL连接到Websphere MQ 7.0的测试环境,所以在开始从JMS端配置SSL连接之前,我必须自己在Websphere MQ上配置SSL

So, I'm trying to create SSL certificates for Websphere MQ, following these steps. 因此,我正在尝试按照这些步骤为Websphere MQ创建SSL证书。 But when I attempt to add the signed certificate to the repository using the command gsk7cmd.exe -cert -receive -db key.kdb -pw pass -file QMANAGER_signed.arm I get the error: 但是当我尝试使用命令gsk7cmd.exe -cert -receive -db key.kdb -pw pass -file QMANAGER_signed.arm将签名证书添加到存储库时,我收到错误:

An attempt to receive the certificate has failed.
All the signer certificates must exist in the key database.

I even tried the C command gsk7capicmd but it also fails, with the error: 我甚至尝试了C命令gsk7capicmd但它也失败了,错误:

Error: 146

Error id: GSKKM_ERR_INVALID_CERT_CHAIN
Details: QMANAGER_signed.arm

UPDATE 1: 更新1:

I used the WMQ SSL Wizard to create the proper configuration. 我使用WMQ SSL向导来创建正确的配置。 The configuration went smoothly, but when I run the JMS sample included with the SSL Wizard I get the error: MQJE001: Completion Code '2', Reason '2397' the SSL logs (using the option -Djavax.net.debug=all ) shows the following error: 配置进行得很顺利,但是当我运行SSL向导附带的JMS示例时,我得到错误: MQJE001: Completion Code '2', Reason '2397'日志(使用选项-Djavax.net.debug=all )显示以下错误:

Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2397;AMQ9771: SSL handshake failed. [1=javax.net.ssl.SSLHandshakeExcep
tion[Remote host closed connection during handshake],3=localhost/127.0.0.1:1414 (localhost),4=SSLSocket.startHandshake,5
=default]
        at com.ibm.mq.jmqi.remote.internal.RemoteTCPConnection.protocolConnect(RemoteTCPConnection.java:995)
        at com.ibm.mq.jmqi.remote.internal.system.RemoteConnection.connect(RemoteConnection.java:989)
        at com.ibm.mq.jmqi.remote.internal.system.RemoteConnectionPool.getConnection(RemoteConnectionPool.java:293)
        at com.ibm.mq.jmqi.remote.internal.RemoteFAP.jmqiConnect(RemoteFAP.java:1371)
        at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:331)
        ... 7 more
Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
        at com.ibm.jsse2.jc.a(jc.java:380)
        at com.ibm.jsse2.jc.g(jc.java:115)
        at com.ibm.jsse2.jc.a(jc.java:240)
        at com.ibm.jsse2.jc.startHandshake(jc.java:54)
        at com.ibm.mq.jmqi.remote.internal.RemoteTCPConnection.protocolConnect(RemoteTCPConnection.java:989)
        ... 11 more
Caused by: java.io.EOFException: SSL peer shut down incorrectly
        at com.ibm.jsse2.a.a(a.java:7)
        at com.ibm.jsse2.jc.a(jc.java:493)
        ... 15 more

UPDATE 2: 更新2:

Using T.Rob's diagnostic technique mentioned in his answer, I'm still stuck at point #3 with the same error as before. 使用T.Rob在他的回答中提到的诊断技术,我仍然停留在第3点,与之前的错误相同。

The error that you are seeing is because your keystore does not have the signing CA's root and/or intermediate signer certificates. 您看到的错误是因为您的密钥库没有签名CA的根和/或中间签名者证书。 When you get a signed certificate back from the Certificate Authority it must be validated before adding it to the keystore. 从证书颁发机构获得签名证书后,必须先将其验证,然后再将其添加到密钥库。 Pretty much anyone could have intercepted your signing request and signed the certificate. 几乎任何人都可以拦截您的签名请求并签署证书。 The step of validating it when received insures that it was signed by a CA that you actually trust and not some anonymous man-in-the-middle. 收到时验证它的步骤确保它是由您实际信任的CA签署的,而不是一些匿名的中间人。

The way the cert is validated is by checking the CA signature against the public key of the CA that is in your KDB. 验证证书的方式是通过根据KDB中CA的公钥检查CA签名。 For that the CA's certificate must already be in the KDB when you attempt to receive your signed cert. 为此,当您尝试接收已签名的证书时,CA的证书必须已在KDB中。 If the CA uses an intermediate signer certificate (and for a variety of reasons any commercial CA will use intermediate certs) then you must also have imported the intermediate cert and the root cert. 如果CA使用中间签名者证书(并且由于各种原因,任何商业CA 使用中间证书),那么您还必须导入中间证书根证书。 This forms a certificate chain or certificate path from the CA's root cert through any intermediate certs to your signed certificate. 这形成了从CA的根证书到任何中间证书到签名证书的证书链或证书路径。 Each thing in the chain is authenticated by the thing above it until you get to the root. 链中的每个东西都由它上面的东西验证,直到你到达根。 Your KDB must have the entire chain and because each cert is validated by the one above it, you must import these beginning with the root and working your way down. 您的KDB 必须拥有整个链,并且因为每个证书都由上面的证书验证,您必须从根目录开始导入这些证书并逐步完成。

Typically your CA will have posted their signer certs on their web site where you retrieve them using SSL. 通常,您的CA会在其网站上发布其签名者证书,您可以使用SSL检索这些证书。 Fetch those and import them and you will be able to receive your signed cert. 获取并导入它们,您将能够收到您签名的证书。

As it happens, The Sphere Online Journal just published an article that walks you through this process using Verisign as an example, and with screen shots of importing the root and intermediate signer certs. 碰巧的是,The Sphere Online Journal刚刚发布了一篇文章,以Verisign为例介绍了这个过程,以及导入root和中间签名者证书的屏幕截图。 The article is about Renewing WebSphere MQ Certificates but the first part of the article creates a kdb file and a signing request, then imports the CA certs and the signed cert. 本文是关于续订WebSphere MQ证书的,但本文的第一部分创建了一个kdb文件和一个签名请求,然后导入了CA证书和签名的证书。

Let's also get you to the correct Infocenter. 让我们也到达正确的信息中心。 Please look at the WMQ v7.0 Infocenter's section on Using CA Signed Certificates . 请查看WMQ v7.0信息中心有关使用CA签名证书的部分。 The one you were looking at is for Message Broker and quite frankly the article you linked to is a bit of a mess. 您正在查看的是Message Broker,坦率地说,您链接的文章有点混乱。 I'll see about getting it fixed. 我会看到修复它。 For starters, that bit about creating the cert in one kdb, getting it signed, then exporting it, deleting it and importing it to the QMgr's KDB is pure rubbish. 对于初学者来说,关于在一个kdb中创建证书,将其签名,然后导出,删除它并将其导入QMgr的KDB这一点是纯粹的垃圾。 Just generate the CSR in the QMgr's own KDB file and receive the signed cert directly to it. 只需在QMgr自己的KDB文件中生成CSR,并直接接收签名证书。 This is much easier and is the process illustrated in the article mentioned above. 这更容易,并且是上述文章中说明的过程。

Finally, if you go to t-rob.net and download the WMQ Security Lab from IMPACT 2011 you will find there a lab guide and some scripts. 最后,如果你去t-rob.net并从IMPACT 2011下载WMQ安全实验室,你会发现有实验室指南和一些脚本。 These use self-signed certificates but the scripts can easily be converted to use CA signed certificates and then tailored for use in your WMQ network. 它们使用自签名证书,但脚本可以轻松转换为使用CA签名证书,然后针对您的WMQ网络进行定制。

UPDATE: 更新:
Responding to he additional questions in the comments: 在评论中回答他的其他问题:

I'm actually planning to use a self-signed certificate, so I guess I only need to extract it and adding it to the client's trust store? 我实际上打算使用自签名证书,所以我想我只需要提取它并将其添加到客户端的信任存储区?

Yes, that is correct. 对,那是正确的。 But here's a problem in the WMB Infocenter page that was originally linked in that it asks you to create a cert with the label qmgrname instead of ibmwebspheremqqmgrname . 但这是WMB信息中心页面中的一个问题,该页面最初是链接的,它要求您创建一个标签为qmgrname而不是ibmwebspheremqqmgrname The QMgr finds its cert based on the label and so it must match the specified format. QMgr根据标签查找其证书,因此它必须与指定的格式匹配。 So when you create your self-signed cert, mke sure that the label is the literal ibmwebspheremq with the QMgr name folded to lower case appended. 因此,当您创建自签名证书时,请确保标签是文字ibmwebspheremq ,其中QMgr名称折叠为附加小写。 If you have made a cert with the wrong label, you can always export it to a P12 file and then import it to a new KDB with the right label. 如果您使用错误的标签制作了证书,则可以始终将其导出到P12文件,然后将其导入到具有正确标签的新KDB。

I used the WMQ SSL Wizard mentioned in the WMQ Security Lab to create the proper configuration. 我使用WMQ安全实验室中提到的WMQ SSL向导来创建正确的配置。 The configuration went smoothly, but when I run the JMS sample included with the SSL Wizard I get the error MQJE001: Completion Code '2', Reason '2397' , the SSL logs shows the following error main, received EOFException: error main, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake main, SEND TLSv1 ALERT: fatal, description = handshake_failure 配置进行顺利,但是当我运行SSL向导附带的JMS示例时,我得到错误MQJE001: Completion Code '2', Reason '2397' ,SSL日志显示以下错误main, received EOFException: error main, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake main, SEND TLSv1 ALERT: fatal, description = handshake_failure

There are a few reasons why that might occur. 可能会出现这种情况的原因有几个。 Rather than going through all of them, I'll suggest some diagnostic techniques. 我会建议一些诊断技术,而不是通过所有这些。 When I set up SSL channels, I always use the following procedure: 当我设置SSL通道时,我总是使用以下过程:

  1. Get the channel running without SSL. 在没有SSL的情况下运行通道。 This proves that the basic communication path is working (listener running, ports match, channel object definitions match, etc.). 这证明基本通信路径正在工作(侦听器运行,端口匹配,通道对象定义匹配等)。
  2. If this is the first time that the QMgr is using SSL, or if the kdb has changed, be sure to issue the REFRESH SECURITY TYPE(SSL) command. 如果这是QMgr第一次使用SSL,或者kdb已更改,请务必发出REFRESH SECURITY TYPE(SSL)命令。
  3. Enable SSL by specifying the same ciphersuite at the QMgr and client but be sure that the QMgr's SVRCONN channel is set to SSLCAUTH(OPTINAL) SSLPEER() . 通过在QMgr和客户端指定相同的密码套件来启用SSL,但要确保QMgr的SVRCONN通道设置为SSLCAUTH(OPTINAL) SSLPEER() This verifies that the client accepts the QMgr's certificate. 这将验证客户端是否接受QMgr的证书。 Only when this works, go to the next step. 只有在此工作时,请转到下一步。
  4. Now change the QMgr's SVRCONN to SSLCAUTH(REQUIRED) SSLPEER() . 现在将QMgr的SVRCONN SSLCAUTH(REQUIRED) SSLPEER()SSLCAUTH(REQUIRED) SSLPEER() This causes the QMgr to request the client's certificate. 这会导致QMgr请求客户端的证书。
  5. If using SSLPEER set it to the desired value. 如果使用SSLPEER将其设置为所需的值。

This process isolates the possible problems so that at any point you know where to look. 此过程隔离了可能出现的问题,以便您随时知道要查找的位置。 If the process fails in Step #3 then there is either an issue with the SSL configuration of the application, or it cannot validate the QMgr's cert. 如果该过程在步骤#3中失败,则存在应用程序的SSL配置问题,或者它无法验证QMgr的证书。 If the process fails in Step #4 then we know the application's SSL configuration is sound and that it likes the QMgr's cert bu that the QMgr doesn't like the application cert. 如果该过程在步骤#4中失败,那么我们知道应用程序的SSL配置是合理的,并且它喜欢QMgr的证书,即QMgr不喜欢应用程序证书。 If we get to Step #5 then it's just a matter of getting the SSLPEER value correct. 如果我们进入第5步,那么只需要获得SSLPEER值就可以了。

Because you got a handshake failure that appears to be due to the QMgr closing the TCP connection, I am assuming that you have SSLCAUTH(REQUIRED) (which is the default, by the way) and that either the QMgr doesn't have the application's certificate or that you were attempting to use an anonymous connection where the client doesn't require a personal cert. 因为你的握手失败似乎是由于QMgr关闭TCP连接,我假设你有SSLCAUTH(REQUIRED) (这是默认的,顺便说一下)并且QMgr没有应用程序的证书或您尝试使用匿名连接,客户端不需要个人证书。 If that is the case, setting SSLCAUTH(OPTIONAL) will get you past the point of failure - although possibly to an entirely new point of failure. 如果是这种情况,设置SSLCAUTH(OPTIONAL)将使您超越故障点 - 尽管可能是一个全新的故障点。

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

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