Thursday, 10 September 2015

Every day is a school day - WebSphere Application Server to WebSphere MQ via TLS 1.2

Following my previous posts: -

I had one outstanding question - why did WebSphere MQ throw up nasty certificate validation errors when I attempted to start a Message Driven Bean that uses a JMS Activation Specification to connect, via TLS 1.2, to an encrypted Channel.

The WAS logs were chock full of errors: -

Caused by: CC=2;RC=2397;AMQ9204: Connection to host '' rejected. [[CC=2;RC=2397;AMQ9771: SSL handshake failed. [[ Broken pipe], (,4=SSLSocket.startHandshake,5=default]],,5=RemoteTCPConnection.protocolConnect]

Caused by: CC=2;RC=2397;AMQ9771: SSL handshake failed. [[ Broken pipe], (,4=SSLSocket.startHandshake,5=default]

Caused by: Broken pipe

[10/09/15 16:14:08:647 BST] 00000088 SibMessage    W   [:] CWSJY0003W: MQJCA4023: Startup reconnection failed for ActivationSpec 'javax.jms.Queue:jms/TESTQ@TESTQM <-1279839562>'. Exception details: '
                       Message : JMSWMQ0018: Failed to connect to queue manager 'TESTQM' with connection mode 'Client' and host name ''.
Check the queue manager is started and if running in client mode, check there is a listener running. Please see the linked exception for more information.

     Caused by [1] --> Message : JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2397' ('MQRC_JSSE_ERROR').

when I attempted to start the MDB.

This was what I saw in the MQ Queue Manager error log: -

cat ~/qmgrs/TESTQM/errors/AMQERR01.LOG 

AMQ9633: Bad SSL certificate for channel '????'.

A certificate encountered during SSL handshaking is regarded as bad for one of
the following reasons: 
(a) it was formatted incorrectly and could not be validated 
(b) it was formatted correctly but failed validation against the Certification
  Authority (CA) root and other certificates held on the local system 
(c) it was found in a Certification Revocation List (CRL) on an LDAP server 
(d) a CRL was specified but the CRL could not be found on the LDAP server 
(e) an OCSP responder has indicated that it is revoked 

The channel is '????'; in some cases its name cannot be determined and so is
shown as '????'. The remote host is 'bpm856 ('. The channel did
not start. 

The details of the certificate which could not be validated are

The certificate validation error was 575010.

Through trial and error, and the essential intervention of a friend, we realised that the problem was relatively simple :-)

We're using a SSL Configuration and a Dynamic Outbound Endpoint SSL Configuration to ensure that WAS connects to MQ on a specific Channel with the MQ Signer Certificate.

In essence, WAS is, by default, sending its personal certificate, signed by WAS' own signer certificate to MQ.

Now the MQ Queue Manager Channel has a setting - SSLCAUTH - which is set to OPTIONAL.

If this was set to REQUIRED, then I'd expect MQ to require WAS to provide a certificate, for two-way client authentication.

However, I assumed that OPTIONAL was ... optional.

Therefore, because WAS is sending a default certificate, MQ is expecting to validate it - and is unable to do so.

There are two solutions: -

Weak Security

Change the WAS configuration to AVOID sending the default certificate: -

specifically this pertains to the Default Client Certificate Alias used within the SSL Configuration. In the screenshot above, the alias needs to be set to (none) rather than (default).

Stronger Security

Export the Signer Certificate from WAS e.g.

AdminTask.extractSignerCertificate('[-keyStoreName CellDefaultTrustStore -keyStoreScope (cell):BAMCell1 -certificateFilePath /tmp/signer.cer -base64Encoded true -certificateAlias root ]')

and import it into the MQ key store: -

runmqckm -cert -add -db ~/SSL/keystore.kdb -pw passw0rd -file /tmp/signer.cer -format ascii

giving us this: -

runmqckm -cert -list -db ~/SSL/keystore.kdb -pw passw0rd 

Certificates in database /var/mqm/SSL/keystore.kdb:
   ", OU=Root Certificate, OU=BAMCell1, OU=Dmgr, O=IBM, C=US"

and then refresh the MQ SSL security configuration: -


( Note that this command will terminate any active SSL/TLS channels, so take care to run it at a suitable time )


Once either approach is followed, the MDB starts happily, and works a treat.

For the record, this was immensely useful: -

as was this: -

No comments: