Using A CCDT in JSON With SSL-TLS With The IBM MQ Sample Amqsputc
Using A CCDT in JSON With SSL-TLS With The IBM MQ Sample Amqsputc
Using a CCDT in JSON with SSL/TLS with the IBM MQ sample amqsputc
https://www.ibm.com/support/pages/node/6955535
Angel Rivera
IBM MQ Support
https://www.ibm.com/products/mq/support
Find all the support you need for IBM MQ
The objective of this tutorial is to describe how to use a CCDT in JSON with SSL/TLS with
the IBM MQ sample: amqsputc
For historical legacy, the term "SSL" is being used in this tutorial in general and includes
TLS.
The approach taken here is conservative and gradual. The idea is to begin with a solid
baseline and subsequent steps are discreet and narrow in scope. In case that there is an
error, it needs to be fixed before taking the next step.
Why? Because if you try to implement everything at once and then you encounter an error,
where do you begin the troubleshooting task? And the answer to this rhetorical question is:
well, it is difficult to troubleshoot such scenario when there are many possible candidates!
One important aspect to consider is that the MQ Client application does NOT need to be
aware if SSL is being used or not used: the underlying MQ client shared-libraries are the
ones that will handle the SSL aspects!
Of course, the configuration of the SSL certificates and SSL-enabled channels need to be
done by the user and the MQ administrator, and this is the part that is the most confusing to
do correctly.
First, we need to ensure that non-SSL server-connection channels can be used with the MQ
sample amqsputc (that puts a message): beginning with using only the simple environment
variable MQSERVER and then a CCDT in JSON that does not use SSL.
Secondly, only after all errors encountered with the first step are fixed, then we test the
SSL/TLS server-connection channel with the MQ sample "amqssslc".
Thirdly, only after all errors encountered with the first and second steps are fixed, then you
can proceed to test your client application with the CCDT JSON that uses SSL. In that way,
if you encounter errors, they will most likely be contained with that client application and
not with the certificates, the SSL channel, and the CCDT.
Page 2 of 23
The following MQ samples are used. They are included with the MQ Samples fileset on the
installation image for the MQ server and the MQ client.
amqsputc => to put a message, using server-connection channel via MQSERVER and CCDT
amqssslc => to connect to a queue manager using SSL without CCDT.
It is recommended that you copy all the commands in this section and paste
them in a plain text editor such as Notepad, which uses monospace font and no wrap
around the lines.
Then make global replacements for the items such as key database, passwords, user name,
queue manager, etc.
Finally, you can copy from Notepad each command and execute it in a command prompt for
Window or for the remote host in Linux.
ATTENTION: Some commands are very long and they may take multiple lines in this
document, but they are really a single long line! You need to ensure that you run the long
single line!
Page 3 of 23
++ References:
The following tutorials provide step-by-step instructions for performing specific tasks.
It is recommended that you download the PDFs and have then handy!
https://www.ibm.com/support/pages/node/1135522
Configuring IBM MQ to use a dedicated Listener, Channel and Queue in Linux
Note: If you have already one MQ Listener, there is no really need to create another one
and you can skip the step to create another Listener from the following tutorial:
.
Chapter 1: User "root" adds the proper user and group in both hosts
Chapter 2: MQ administrator (user "mqm") creates a queue manager with the basic/normal
objects in host-1
Chapter 3: MQ administrator adds the dedicated objects.
- Listener (such as MY.LISTENER in port 1420)
- Server-Connection Channel (such as MY.CHANNEL)
- Channel Authentication Record (CHLAUTH) for this server-connection channel that allows
only the user "fulano" who is a member of the group "mqusers".
- Queue (such as MY.Q)
- Authority records for group "mqusers" to display, put, get, browse, etc. from the
dedicated queue.
Chapter 4: User "fulano" from host-2 puts and gets messages using the dedicated objects
https://www.ibm.com/support/pages/node/6470619
Using SSL TLS in MQ 9.2 to connect a C-based client in Windows to a queue manager in
Linux, using self-signed certificates, 2-way authentication
The objective of this document is to provide step-by-step details:
- To connect an MQ 9.2 C-based client from Windows
… to a single-instance queue manager running MQ 9.2 in Linux,
… using self-signed certificates for 2-way authentication (client authenticates the queue
manager, and the queue manager authenticates the client).
- The MQ sample amqssslc is used for testing, because it does not require an MQ CCDT file.
- The MQ sample amqsputc is also used for testing placing a message into queue Q1, and it
requires a CCDT file (for this tutorial it uses JSON format).
For illustration purposes the following protocol will be used:
TLS 1.3 compliant: TLS_AES_128_GCM_SHA256
Page 4 of 23
https://www.ibm.com/support/pages/node/6568807
Using IBM MQ CCDT file in JSON format
This feature was introduced in MQ 9.1.2 CD and it is available in MQ 9.2 LTS and CD.
There are several examples and the complete JSON file for each of the examples is
included.
- Example 1: Very simple CCDT file: 1 channel, 1 queue manager, no SSL/TLS
- Suggestion to use MQSERVER in host-2 to validate basic connectivity
- Unset MQSERVER and MQCLNTCF
- Creating a CCDT JSON file
- Specifying the MQ environment variables for the CCDT file
- Example 2: CCDT file for 1 channel, 1 queue manager using SS/TLS.
- Example 3: CCDT for 1 multi-instance queue manager, no SSL/TLS
- Using “runmqsc -n” to view the clients defined in the CCDT file
- Troubleshooting Scenario
- Using ccdt_schema.json provided with MQ to validate the CCDT file.
- How to unset MQ environment variables regarding Connectivity
https://www.ibm.com/support/pages/node/6430633
Connection precedence hierarchy for MQ Clients: PreConnect Exit, MQCONN API, MQSERVER,
mqclient.ini, CCDT
5: Referenced as [Troubleshooting]
https://www.ibm.com/support/pages/6955529
Exploring some troubleshooting scenarios for SSL/TLS in IBM MQ
The objective of this document is to document the errors encountered during the
preparation of a tutorial on MQ and SSL, what do the errors look like and how they were
resolved.
The scenarios are:
Scenario 1: CipherSpec specified by the MQ Client does not match the required one
Scenario 2: Label specified by the MQ Client does not match the one from the Client
certificate
Scenario 3: Using a TLS 1.2 CipherSpec but the queue manager expects only TLS 1.3
Scenario 4: Specifying suffix (kdb) for keystore, 2381 MQRC_KEY_REPOSITORY_ERROR
Scenario 5: Dealing with an expired client certificate
Scenario 6: MQSERVER does not support SSL/TLS
Page 6 of 23
The following hosts and MQ objects were used for this tutorial.
* Section A: Host-1 Linux, Queue manager. From reference [Basic config qmgr]
- As user "root"
- As user "mqm"
Setup the environment variables for MQ. You need to "source" the command in Linux, that
is, start with a dot, then a space and then the rest.
. /opt/mqm/bin/setmqenv -n Installation1
## Define queue:
DEFINE QLOCAL(Q1)
## Security note: the following ALTER is not suitable for PRODUCTION but might be suitable
for TEST queue managers.
## For testing queue managers: disable userid/password for remote users
ALTER AUTHINFO(SYSTEM.DEFAULT.AUTHINFO.IDPWOS) AUTHTYPE(IDPWOS) CHCKCLNT(OPTIONAL)
REFRESH SECURITY TYPE(CONNAUTH)
Page 8 of 23
## Security note: the following CHLAUTH records may not be suitable for PRODUCTION but
might be suitable for TEST queue managers.
## For testing queue managers: allow MQ Administrator to remotely access the queue
manager
SET CHLAUTH(*) TYPE(BLOCKUSER) USERLIST('nobody','*MQADMIN')
SET CHLAUTH(SYSTEM.ADMIN.*) TYPE(BLOCKUSER) USERLIST('nobody')
SET CHLAUTH(SYSTEM.DEF.SVRCONN) TYPE(ADDRESSMAP) ADDRESS(*) USERSRC(CHANNEL)
SET CHLAUTH(SYSTEM.DEF.*) TYPE(BLOCKUSER) USERLIST('nobody')
## Allow the following SVRCONN to be accessed by an administrator
SET CHLAUTH(NON.SSL.SVRCONN) TYPE(BLOCKUSER) USERLIST('nobody')
END
Page 9 of 23
The objective of this step is to ensure that a plain non-SSL server-connection channel can
be used to connect the MQ client from host-2 to the MQ queue manager in host-1.
There could be several issues that can be encountered at this time, such as:
- firewall problems
- wrong host or port specified by the MQ client application
- incorrect userid
- incomplete authorizations for the remote user
- listener for the queue manager not running
… etc …
# Add the MQ directory with the samples into the PATH (not added by setmqenv)
export PATH=$PATH:$MQ_INSTALLATION_PATH/samp/bin
Set the MQSERVER environment variable, which has the HIGHEST PRECEDENCE over other
MQ environment variables:
export MQSERVER='NON.SSL.SVRCONN/TCP/volterra1.fyre.ibm.com(1419)'
$ amqsputc Q1 QM93TLS
Sample AMQSPUT0 start
target queue is Q1
THIS IS A TEST MESSAGE
Sample AMQSPUT0 end
If the test was not successful, then you need to take a pause here, and ensure to fix the
current problem(s) before proceeding with SSL.
Page 10 of 23
The objective of this step is to ensure that a plain non-SSL server-connection channel can
be used to connect the MQ client from host-2 to the MQ queue manager in host-1.
Set the MQSERVER environment variable, which has the HIGHEST PRECEDENCE over other
MQ environment variables:
set MQSERVER=NON.SSL.SVRCONN/TCP/volterra1.fyre.ibm.com(1419)
If the test was not successful, then you need to take a pause here, and ensure to fix the
current problem(s) before proceeding with SSL.
Page 11 of 23
OK, now that we have confirmed that the remote client can connect successfully using
normal non-SSL channels, we can proceed to do the configurations for SSL.
Note:
After stashing the kdb password, you could to use the -stashed command line option than to
specify the -pw option.
runmqsc QM93TLS
## (TEST machines) The following is to allow the remote access from MQ Administrators
SET CHLAUTH(SSL.SVRCONN.*) TYPE(BLOCKUSER) USERLIST('nobody')
END
Page 13 of 23
export MQSSLKEYR=/var/mqm/ssl/clientkey
runmqckm -keydb -create -db /var/mqm/ssl/clientkey.kdb -pw clientpass -type cms -stash
Exchange keys with the host that has the queue manager
The crt file from the queue manager is expected to be received at:
/var/mqm/ssl/QM93TLS.crt
You must ensure that the received *.crt files have ownership of "mqm"mqm" and
at least rw permissions for user, such as:
-rw------- 1 mqm mqm 1118 Feb 12 13:19 /var/mqm/ssl/QM93TLS.crt
ATTENTION! You should not try yet to connect via SSL, because it is necessary to
update the key repository of the queue manager!
Page 14 of 23
Exchange keys with the host that has the queue manager
The crt file from the queue manager is expected to be received at:
C:\ProgramData\IBM\MQ\ssl\QM93TLS.crt
ATTENTION! You should not try yet to connect via SSL, because it is necessary to
update the key repository of the queue manager!
Page 15 of 23
ATTENTION!!
Because the key repository was modified, it is necessary to refresh the security via
runmqsc.
runmqsc QM93TLS
REFRESH SECURITY TYPE(SSL)
END
(Additional details)
Note regarding the deletion of a certificate (reuse the one for “-cert -details” and
replace it with “-cert -delete)
Do NOT include the suffix .kdb in for the key repository, argument -k
Do NOT include the suffix .kdb in for the key repository, argument -k
* Section J: Host-2 Linux, Client. From references [CCDT in JSON] and [Connection
precedence]
Location: /var/mqm/ssl
File name: ccdt-QM93TLS-volterra1-nonssl.json
Now you MUST unset the environment variables MQSERVER and MQCLNTCF.
Why? Because MQSERVER has the highest precedence in the connectivity hierarchy and the
presence of MQSERVER will NOT allow you to use CCDT.
The presence of MQSERVER is a VERY COMMON ERROR when customers try to use their CCDT
file.
For completeness, just in case that you are using the mqclient.ini (Client Configuration
file), unset the following variable, which has higher precedence than the CCDT ones.
$ unset MQCLNTCF
Page 19 of 23
Proceed to set the following 2 environment variables that provide the full path of the CCDT
file:
$ export MQCHLLIB=/var/mqm/ssl
$ export MQCHLTAB=ccdt-QM93TLS-volterra1-nonssl.json
Notice that you need to have the environment variable that points to the key repository:
$ export MQSSLKEYR=/var/mqm/ssl/clientkey
$ amqsputc Q1 QM93TLS
Sample AMQSPUT0 start
target queue is Q1
this is a test using CCDT JSON using normal (non SSL) channel
The purpose of this test is to ensure that the environment variables are properly set and
that the CCDT is being used.
As an extra step to confirm that the CCDT file is being used, you can introduce a typo in the
host name inside the CCDT file and repeat.
For example, I deleted one letter from the host name inside the CCDT. That is. This was the
only change. Then I repeated the sample:
$ amqsputc Q1 QM93TLS
Sample AMQSPUT0 start
MQCONNX ended with reason code 2538
$ mqrc 2538
2538 0x000009ea MQRC_HOST_NOT_AVAILABLE
Please remember to modify the CCDT file to revert back to the valid host name.
Page 20 of 23
Location: /var/mqm/ssl
File name: ccdt-QM93TLS-volterra1-linux-ssl.json
Proceed to set the following 2 environment variables that provide the full path of the CCDT
file:
$ export MQCHLLIB=/var/mqm/ssl
$ export MQCHLTAB=ccdt-QM93TLS-volterra1-linux-ssl.json
Notice that you need to have the environment variable that points to the key repository:
$ export MQSSLKEYR=/var/mqm/ssl/clientkey
$ amqsputc Q1 QM93TLS
Sample AMQSPUT0 start
target queue is Q1
This is a test using CCDT JSON using SSL
Sample AMQSPUT0 end
Page 21 of 23
* Section K: Host-2 Windows, Client. From references [CCDT in JSON] and [Connection
precedence]
Location: C:\ProgramData\IBM\MQ\ssl
File name: ccdt-QM93TLS-volterra1-nonssl.json
Now you MUST unset the environment variables MQSERVER and MQCLNTCF.
Why? Because MQSERVER has the highest precedence in the connectivity hierarchy and the
presence of MQSERVER will NOT allow you to use CCDT.
The presence of MQSERVER is a VERY COMMON ERROR when customers try to use their CCDT
file.
For completeness, just in case that you are using the mqclient.ini (Client Configuration
file), unset the following variable, which has higher precedence than the CCDT ones.
set MQCLNTCF=
Page 22 of 23
Proceed to set the following 2 environment variables that provide the full path of the CCDT
file:
set MQCHLLIB=C:\ProgramData\IBM\MQ\ssl
set MQCHLTAB=ccdt-QM93TLS-volterra1-nonssl.json
Notice that you need to have the environment variable that points to the key repository:
set MQSSLKEYR=C:\ProgramData\IBM\MQ\ssl\clientkey
The following command will show you all the MQ environment variables. Here we show only
the ones of interest.
C:\> set MQ
MQCHLLIB=C:\ProgramData\IBM\MQ\ssl
MQCHLTAB=ccdt-QM93TLS-volterra1-nonssl.json
MQSSLKEYR=C:\ProgramData\IBM\MQ\ssl\clientkey
…
The purpose of this test is to ensure that the environment variables are properly set and
that the CCDT is being used.
As an extra step to confirm that the CCDT file is being used, you can introduce a typo in the
host name inside the CCDT file and repeat.
For example, I deleted one letter from the host name inside the CCDT. That is. This was the
only change. Then I repeated the sample:
Please remember to modify the CCDT file to revert back to the valid host name.
Page 23 of 23
Location: C:\ProgramData\IBM\MQ\ssl
File name: ccdt-QM93TLS-volterra1-windows-ssl.json
Notice that you need to have the environment variable that points to the key repository:
set MQSSLKEYR=C:\ProgramData\IBM\MQ\ssl\clientkey