You want to use certificates to authenticate access to a mqweb server. You can use self signed, which is fine for test and small environments, or use signed certificate which are suitable for production, and typical environments. Using certificates means you do not need to specify userid and password.
The userid is taken from the CN part of the subject, and this userid is used to grant access depending on the configuration in the mqwebuser.xml file.
This section assumes you have set up your mqweb using a certificate authority.
Information about certificates used for authentication are stored in the trust store. For a CA signed certificate, you only need the CA certificates, not the individual certificates. With self signed, you need a copy of the individual self signed certificate.
Create the trust store if required.
/opt/mqm/bin/runmqckm -keydb -create -db trust.jks -pw zpassword -type jks
You need to do this once.
Add the CA certificate to the trust store
/opt/mqm/bin/runmqckm -cert -add -db trust.jks -file cacert.pem -label CACert -type jks -pw zpassword
You need to do this for each CA certificate you want to add, giving each CA a unique label.
You need to restart mqweb so it picks up any changes to the trust store, but as you will be changing the mqwebuser.xml – the restart can wait will later.
Create the certificate request for the end user
openssl req -config client.cnf -newkey rsa:2048 -out colinpaice.csr -outform PEM -keyout colinpaice.key.pem -subj “/C=GB/O=cpwebuser/CN=colinpaice” -extensions client_extensions -passin file:password.file -passout file:password.file
- openssl req – the absence of -x509 makes this a certificate request
- -config client.cnf – use this config file
- -newkey rsa:2048 – create a new private key with 2048 bits rsa key
- -out colinpaice.csr – put the request in this file
- -outform PEM – with this format
- -keyout colinpaice.key.pem – put the key in this file
- -subj “/C=GB/O=cpwebuser/CN=colinpaice” – this is the DN. The CN= is the userid used by mqweb to determine the role. It must match the case of userid
- -extensions client_extensions – see below
- -passin file:password.file -passout file:password.file – passwords are in this file
[ client_extensions ] subjectKeyIdentifier = hash # basicConstraints = CA:FALSE subjectAltName = DNS:localhost, IP:127.0.0.1 nsComment = "OpenSSL ColinClient" keyUsage = critical, nonRepudiation,digitalSignature, extendedKeyUsage = critical, clientAuth
You need to do this for each user.
Send the certificate request to your CA. You can use the following command to sign it.
openssl ca -config openssl-ca-user.cnf -policy signing_policy -extensions signing_req -md sha256 -keyfile cacert.key.pem -out colinpaice.pem -infiles colinpaice.csr
- openssl ca – the signing request
- -config openssl-ca-user.cnf – use this config file
- -policy signing_policy – defines the requirements for the DN. See below
- -extensions signing_req – see below
- -md sha256 – what encryption to be used for the message digest
- -keyfile cacert.key.pem – the CA authorities private key
- -out colinpaice.pem – where the output goes
- -infiles colinpaice.csr – the input file that needs signing
Send the *.pem file back to the requestor.
You need to do this for each user.
The signing policy allows the CA administrator to define which elements are required in the DN.
[ signing_policy ] organizationName = supplied commonName = supplied
The certificate needs extensions which say how the certificate can be used.
[ signing_req ] subjectKeyIdentifier = hash authorityKeyIdentifier = keyid,issuer basicConstraints = CA:FALSE keyUsage = digitalSignature extendedKeyUsage = clientAuth
Create an intermediate pkcs12 keystore so certificate can be imported
You need to import the certificate and private key into the browser’s keystore. The only way I found of doing this was via an intermediate pkcs12 keystore (with extension .p12). If you import the certificate and key from the web browser, it will expect a .p12 file.
openssl pkcs12 -export -inkey colinpaice.key.pem -in colinpaice.pem -out colinpaice.p12 -CAfile cacert.pem -chain -name colinpaice -passout file:password.file -passin file:password.file
- openssl pkcs12 – request to process a pkcs12 keystore
- -export – to create it
- -inkey colinpaice.key.pem – this private key
- -in colinpaice.pem – this certificate returned from the CA
- -out colinpaice.p12 – the name of the temporary key store which is created
- -CAfile cacert.pem – use this CA certificate
- -chain – include any CA certificates with the certificate and key
- -name colinpaice – create this name in the keystore
- -passout file:password.file -passin file:password.file – use these passwords
Import the temporary keystore into the Chrome keystore
pk12util -i colinpaice.p12 -d sql:/home/colinpaice/snap/chromium/986/.pki/nssdb/ -W password
- pk12util – this command
- -i colinpaice.p12 – from the temporary keystore you just created
- -d sql:/home/colinpaice/snap/chromium/986/.pki/nssdb/ – into this key store
- -W password – using this password (for the temporary .p12 file)
Remove the intermediate file
You do not need to import the certificate into the mqweb trust store.
Update the mqweb configuration if required
<webAppSecurity allowFailOverToBasicAuth="false" /> <keyStore id="defaultKeyStore" location="/home/colinpaice/ssl/ssl2/mqweb.p12" type="pkcs12" password="password"/> <keyStore id="defaultTrustStore" location="/home/colinpaice/ssl/ssl2/trust.jks" type="JKS" password="password"/> <ssl id="defaultSSLConfig" keyStoreRef="defaultKeyStore" serverKeyAlias="mqweb" trustStoreRef="defaultTrustStore" sslProtocol="TLSv1.2" clientAuthentication="true" clientAuthenticationSupported="true" />
It is better to stop and restart mqweb if you change the xml config files, otherwise you can get strange errors.
No messages are produced in /var/mqm/web/installations/Installation1/servers/mqweb/logs/messages.log if the trust store was opened successfully.
Use a command like grep ” E ” messages.log and check for messages like
CWPKI0033E: The keystore located at /home/colinpaice/ssl/ssl2/trust.jks did not load because of the following error: Keystore was tampered with, or password was incorrect
Try using it in Chrome
You need to restart Chrome to pick up the changes to its keystore. Use the url chrome://restart/
Use the url chrome://settings/certificates , to check your certificate is present under “Your certificates”. If not use url chrome://version to display the profile being used, and that it matches the store used in the pk12util command above.
Try connecting to mqweb using a url like https://127.0.0.1:9443/ibmmq/console/ .
You should be logged on with no password request. In the top right hand corner of the screen you should have a black circle with a white “i” in it. This shows you are logged on with certificates. Click on this to show how you are logged on.