Tuesday, 17 November 2015

IBM BPM Advanced 8.5.6 - Sorting out the JDBC Data Sources

Following on from a much earlier post: -


I had a requirement to sort out the JDBC data sources / variables that lead to this: -


with an IBM BPM Advanced 8.5.6 installation on Linux on IBM Z ( aka LinuxONE )

Here's the Jython script I used: -

cellID = AdminControl.getCell()

AdminConfig.create('VariableSubstitutionEntry', '(cells/'+cellID+'|variables.xml#VariableMap_1)', '[[symbolicName "DB2_JCC_DRIVER_PATH"] [description ""] [value "${WAS_INSTALL_ROOT}/jdbcdrivers/DB2"]]')

AdminConfig.create('VariableSubstitutionEntry', '(cells/'+cellID+'|variables.xml#VariableMap_1)', '[[symbolicName "WAS_INSTALL_ROOT"] [description ""] [value "/opt/IBM/WebSphere/AppServer"]]')

AdminConfig.create('VariableSubstitutionEntry', '(cells/'+cellID+'|variables.xml#VariableMap_1)', '[[symbolicName "UNIVERSAL_JDBC_DRIVER_PATH"] [description ""] [value "${WAS_INSTALL_ROOT}/jdbcdrivers/DB2"]]')

AdminConfig.create('VariableSubstitutionEntry', '(cells/'+cellID+'|variables.xml#VariableMap_1)', '[[symbolicName "PUREQUERY_PATH"] [description ""] [value ""]]')

AdminConfig.save()
AdminNodeManagement.syncActiveNodes()


and here's the result: -


Thursday, 12 November 2015

IBM HTTP Server and the Strange Story of Line Numbers

One of my colleagues saw an interesting issue with IBM HTTP Server today.

She's using IHS 8.5.5.0 on Linux.

In essence, whilst she could connect to IHS on port 8080 ( non-SSL port ), she couldn't connect on port 8443 ( SSL port ).

There were no obvious exceptions in the IHS error log, so I asked her to enable SSL tracing ( via the SSLTrace directive in httpd.conf ).

This she did, and this is what we saw in the logs: -

[Thu Nov 12 20:17:34 2015] [debug] ssl_getpwd() entry
[Thu Nov 12 20:17:34 2015] [debug] ssl_getpwd processing :0, ssl flag [0] prompt flag [0]
[Thu Nov 12 20:17:34 2015] [info] mod_unique_id: using ip addr 192.168.1.80
[Thu Nov 12 20:17:35 2015] [debug] SSL initialization for server: webserver.uk.ibm.com, port: 8080
[Thu Nov 12 20:17:35 2015] [notice] Using GSKit version 8.0.14.9
[Thu Nov 12 20:17:35 2015] [debug] SSL initialization for server: webserver.uk.ibm.com, port: 8080
[Thu Nov 12 20:17:35 2015] [info] mod_unique_id: using ip addr 192.168.1.80
[Thu Nov 12 20:17:36 2015] [error] ws_config_parser: handleConfigStart: Unknown property StrictSecurity
[Thu Nov 12 20:17:36 2015] [error] ws_config_parser: handleConfigStart: Unknown property MarkBusyDown
[Thu Nov 12 20:17:36 2015] [error] ws_config_parser: handleConfigStart: Unknown property KillWebServerStartUpOnParseErr
[Thu Nov 12 20:17:36 2015] [error] ws_config_parser: handleConfigStart: Unknown property IISDisableFlushFlag
[Thu Nov 12 20:17:36 2015] [notice] PLUGIN: mod_was_ap22_http: apache_log_header: WebSphere Plugins loaded.
[Thu Nov 12 20:17:36 2015] [notice] PLUGIN: mod_was_ap22_http: apache_log_header: --------------------Plugin Information-----------------------
[Thu Nov 12 20:17:36 2015] [notice] PLUGIN: mod_was_ap22_http: apache_log_header: Bld version: 8.5.0
[Thu Nov 12 20:17:36 2015] [notice] PLUGIN: mod_was_ap22_http: apache_log_header: Bld date: Apr 24 2012, 15:17:46
[Thu Nov 12 20:17:36 2015] [notice] PLUGIN: mod_was_ap22_http: apache_log_header: Webserver: IBM_HTTP_Server
[Thu Nov 12 20:17:36 2015] [notice] PLUGIN: mod_was_ap22_http: apache_log_header: --------------------------------------------------------------
[Thu Nov 12 20:17:36 2015] [notice] Using config file /opt/ibm/HTTPServer/conf/httpd.conf 
[Thu Nov 12 20:17:36 2015] [notice] IBM_HTTP_Server/8.5.0.0 (Unix) configured -- resuming normal operations
[Thu Nov 12 20:17:36 2015] [info] Server built: Mar  7 2012 18:25:14
[Thu Nov 12 20:17:36 2015] [debug] worker.c(1859): AcceptMutex: sysvsem (default: sysvsem)
[Thu Nov 12 20:17:36 2015] [notice] Core file limit is 0; core dumps will be not be written for server crashes
[Thu Nov 12 20:17:36 2015] [debug] mod_mpmstats.c(211): mpmstats daemon started (pid 6494)


which was somewhat strange.

This suggested that IHS was trying to bring up SSL on port 8080 rather than 8443.

Also, I noticed that there was almost no SSL debug appearing in the log, implying that SSL was NOT coming up properly / at all.

This is what she had in httpd.conf: -

Listen 8080
ServerName webserver.uk.ibm.com:8080
LoadModule ibm_ssl_module modules/mod_ibm_ssl.so
Listen 8443
<VirtualHost *:8443>
SSLProtocolDisable SSLv2 SSLv3
SSLEnable
</VirtualHost>
KeyFile /opt/IBM/HttpServer/ssl/keystore.kdb
SSLDisable
SSLTrace


which looks OK although I wouldn't normally expect to see the Listen and ServerName directives immediately next to the SSL configuration block.

Note the inclusion of SSLTrace at my request.

I asked her to enable line number in vi in order to see where precisely the SSL configuration block occurs: -

106 #
107 # Listen: Allows you to bind the web server to specific IP addresses
108 # and/or ports, in addition to the default. See also the <VirtualHost>
109 # directive.
110 #
111 # Change this to Listen on specific IP addresses as shown below to
112 # prevent the web server from accepting connections on all interfaces
113 # (0.0.0.0)
114 #
115 # Change this to "Listen 0.0.0.0:port" to restrict the server to
116 # IPv4.
117 #
118 #Listen 12.34.56.78:80
119 Listen 8080
120 ServerName webserver.uk.ibm.com:8080
121 LoadModule ibm_ssl_module modules/mod_ibm_ssl.so
122 Listen 8443
123 <VirtualHost *:8443>
124 SSLProtocolDisable SSLv2 SSLv3
125 SSLEnable
126 </VirtualHost>
127 KeyFile /opt/IBM/HttpServer/ssl/keystore.kdb
128 SSLDisable
129 SSLTrace


I then compared this to a vanilla IHS configuration: -

106 #
107 # Listen: Allows you to bind the web server to specific IP addresses 
108 # and/or ports, in addition to the default. See also the <VirtualHost>
109 # directive.
110 #
111 # Change this to Listen on specific IP addresses as shown below to 
112 # prevent the web server from accepting connections on all interfaces
113 # (0.0.0.0)
114 #
115 # Change this to "Listen 0.0.0.0:port" to restrict the server to
116 # IPv4.
117 #
118 #Listen 12.34.56.78:80
119 Listen 8080


This made me think "Aha, I wonder if the various blocks need to be on specific lines?".

Again, I looked at the vanilla configuration, in order to locate the SSL block: -

848 # Example SSL configuration which supports SSLv3 and TLSv1
849 # To enable this support:
850 #   1) Create a key database with ikeyman
851 #   2) Update the KeyFile directive below to point to that key database
852 #   3) Uncomment the directives up through the end of the example
853 #
854 #LoadModule ibm_ssl_module modules/mod_ibm_ssl.so
855 #Listen 443
856 #<VirtualHost *:443>
857 #SSLEnable
858 #</VirtualHost>
859 #KeyFile /opt/ibm/HTTPServer/ihsserverkey.kdb
860 #SSLDisable
861 # End of example SSL configuration

I don't know for sure, but I'm guessing that's the root cause.

I had her move the Listen and ServerName directives further up the file, and restart ....

As expected, this did the trick, and IHS came up properly on both port 8080 ( HTTP ) and 8443 ( HTTPS ).

Equally importantly, the debug appeared as expected: -

...
[Thu Nov 12 20:26:19 2015] [info] mod_unique_id: using ip addr 192.168.1.80
[Thu Nov 12 20:26:20 2015] [debug] SSL initialization for server: webserver.uk.ibm.com, port: 8080
[Thu Nov 12 20:26:20 2015] [debug] SSL initialization for server: webserver.uk.ibm.com, port: 8443
[Thu Nov 12 20:26:20 2015] [debug] mod_ibm_ssl.c(1604): Accelerator device has not been enabled (0)
[Thu Nov 12 20:26:20 2015] [debug] SSL support provided for SSLV2 cipher: SSL_RC4_128_WITH_MD5(21)
[Thu Nov 12 20:26:20 2015] [debug] SSL support provided for SSLV2 cipher: SSL_RC4_128_EXPORT40_WITH_MD5(22)
[Thu Nov 12 20:26:20 2015] [debug] SSL support provided for SSLV2 cipher: SSL_RC2_CBC_128_CBC_WITH_MD5(23)
[Thu Nov 12 20:26:20 2015] [debug] SSL support provided for SSLV2 cipher: SSL_RC2_CBC_128_CBC_EXPORT40_WITH_MD5(24)
[Thu Nov 12 20:26:20 2015] [debug] SSL support provided for SSLV2 cipher: SSL_DES_64_CBC_WITH_MD5(26)
[Thu Nov 12 20:26:20 2015] [debug] SSL support provided for SSLV2 cipher: SSL_DES_192_EDE3_CBC_WITH_MD5(27)
[Thu Nov 12 20:26:20 2015] [debug] SSL support NOT provided for SSLV2 cipher: TLS_RSA_WITH_AES_128_CBC_SHA(2F)
[Thu Nov 12 20:26:20 2015] [debug] SSL support NOT provided for SSLV2 cipher: TLS_RSA_WITH_NULL_NULL(30)
[Thu Nov 12 20:26:20 2015] [debug] SSL support NOT provided for SSLV2 cipher: TLS_RSA_WITH_NULL_MD5(31)
[Thu Nov 12 20:26:20 2015] [debug] SSL support NOT provided for SSLV2 cipher: TLS_RSA_WITH_NULL_SHA(32)
[Thu Nov 12 20:26:20 2015] [debug] SSL support NOT provided for SSLV2 cipher: TLS_RSA_EXPORT_WITH_RC4_40_MD5(33)
[Thu Nov 12 20:26:20 2015] [debug] SSL support NOT provided for SSLV2 cipher: TLS_RSA_WITH_RC4_128_MD5(34)
[Thu Nov 12 20:26:20 2015] [debug] SSL support NOT provided for SSLV2 cipher: TLS_RSA_WITH_RC4_128_SHA(35)
[Thu Nov 12 20:26:20 2015] [debug] SSL support NOT provided for SSLV2 cipher: TLS_RSA_WITH_AES_256_CBC_SHA(35b)
[Thu Nov 12 20:26:20 2015] [debug] SSL support NOT provided for SSLV2 cipher: TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5(36)
[Thu Nov 12 20:26:20 2015] [debug] SSL support NOT provided for SSLV2 cipher: TLS_RSA_WITH_DES_CBC_SHA(39)

...

Having recreated the problem on my own VM, I confirmed that the problem is definitely related to positioning.

Once I moved the SSL block down to line ~848, it just worked.

I need to think about WHY, but the moral of the story is the positioning of Listen, ServerName and the SSL block is obviously more important than I had realised ...


IBM HTTP Server and the WebSphere Plugin - ws_config_parser: handleLogEnd: Failed to open log file: ' /opt/IBM/Websphere/plugins/logs/webserver2/http_plugin.log', OS Err: 2

I saw this issue this evening: -

[Thu Nov 12 20:07:47 2015] [error] ws_config_parser: handleLogEnd: Failed to open log file: ' /opt/IBM/Websphere/plugins/logs/webserver2/http_plugin.log', OS Err: 2

when starting IBM HTTP Server 8.5.5.0.

I checked my IHS configuration file - httpd.conf - which contained: -

WebSpherePluginConfig /opt/IBM/Websphere/plugins/config/webserver2/plugin-cfg.xml

and checked the Plugin configuration file itself: -

/opt/IBM/Websphere/plugins/config/webserver2/plugin-cfg.xml

which contained: -

   <Log LogLevel="Error" Name=" /opt/IBM/Websphere/plugins/logs/webserver2/http_plugin.log"/>

Note the obvious ?

Yes, there's a space between the quote and the leading /: -

   <Log LogLevel="Error" Name=" /opt/IBM/Websphere/plugins/logs/webserver2/http_plugin.log"/>

Once I removed it: -

   <Log LogLevel="Error" Name="/opt/IBM/Websphere/plugins/logs/webserver2/http_plugin.log"/>

IHS started without problems.

Using -Xgc:preferredHeapBase with -Xcompressedrefs

Saw this IBM Technote via Twitter: -


...
"Why does the JVM report a native out-of-memory (NOOM) when using compressed references? I am using a 64bit JVM and I clearly have plenty of memory left. How can I resolve this problem?"

The IBM JVM will automatically use compressed references when using a maximum heap size less than 25GB. This automated behavior was introduced in Java 626 SR5 and Java 7 SR4*. Compressed references (CR) decreases the size of Java objects making better use of available memory space. This better use of space results in improved JVM performance. *(Java 7 SR1 and later uses compressed references by default on z/OS)
...

Worth a read

Wednesday, 11 November 2015

AMQ9631: The CipherSpec negotiated during the SSL handshake does not match the required CipherSpec for channel

Following on from my earlier post: -


I also saw this: -

11/11/15 20:31:03 - Process(39916.7) User(mqm) Program(amqrmppa)
                    Host(nemdemo.uk.ibm.com) Installation(Installation1)
                    VRMF(8.0.0.0) QMgr(TESTQM)

AMQ9631: The CipherSpec negotiated during the SSL handshake does not match the
required CipherSpec for channel 'TEST.QMGR.SVRCONN'.

EXPLANATION:
There is a mismatch between the CipherSpecs on the local and remote ends of
channel 'TEST.QMGR.SVRCONN'. The channel will not run until this mismatch is
resolved. The CipherSpec required in the local channel definition is
'TLS_RSA_WITH_AES_128_CBC_SHA256'. The name of the CipherSpec negotiated during
the SSL handshake is 'TLS_RSA_WITH_AES_256_CBC_SHA256'. A code is displayed if
the name of the negotiated CipherSpec cannot be determined.
ACTION:
Change the channel definitions for 'TEST.QMGR.SVRCONN' so the two ends have
matching CipherSpecs and restart the channel. If the certificate in use by one
end of the channel is a Global Server Certificate, then the negotiated
CipherSpec may not match that specified on either end of the channel. This is
because the SSL protocol allows a Global Server Certificate to automatically
negotiate a higher level of encryption. In these cases specify a CipherSpec
which meets the requirements of the Global Server Certificate.


in my MQ log - /var/mqm/qmgrs/TESTQM/errors/AMQERR01.LOG.

Again, this happened when I attempted to start the Message Driven Bean (MDB) in WAS, which is the "client" to the MQ "server".

This time around, the message was more meaningful.

The connection from WAS is using a SSL Configuration that asserts a specific Cipher Specification - SSL_RSA_WITH_AES_256_CBC_SHA256 : -

AdminTask.createSSLConfig('[-alias WAS_to_WMQ -type JSSE -scopeName (cell):'+cellID+' -keyStoreName CellDefaultKeyStore -keyStoreScopeName (cell):'+cellID+' -trustStoreName CellDefaultTrustStore -trustStoreScopeName (cell):'+cellID+'  -jsseProvider IBMJSSE2 -sslProtocol TLSv1.2 -clientAuthentication false -clientAuthenticationSupported false -securityLevel HIGH -enabledCiphers SSL_RSA_WITH_AES_256_CBC_SHA256 ]')

whereas the MQ Channel was expecting a slightly different one: -

echo "DIS CHANNEL("TEST.QMGR.SVRCONN") SSLCIPH" | runmqsc TESTQM

5724-H72 (C) Copyright IBM Corp. 1994, 2014.
Starting MQSC for queue manager TESTQM.


     1 : DIS CHANNEL(TEST.QMGR.SVRCONN) SSLCIPH
AMQ8414: Display Channel details.
   CHANNEL(TEST.QMGR.SVRCONN)              CHLTYPE(SVRCONN)
   SSLCIPH(TLS_RSA_WITH_AES_128_CBC_SHA256)
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.

Once I updated the Channel to use the same Cipher Specification as WAS: -

echo "ALTER CHANNEL("TEST.QMGR.SVRCONN") CHLTYPE(SVRCONN) SSLCIPH(TLS_RSA_WITH_AES_256_CBC_SHA256)" | runmqsc TESTQM

the MDB started without problems.




AMQ9660: SSL key repository: password stash file absent or unusable.

I've spent a few happy hours trying to resolve this one.

When attempting to read a message from a WebSphere MQ 8 Queue from WebSphere Application Server (WAS), using a Message Driven Bean (MDB), a JMS Activation Specification and a JMS Queue, I kept seeing this: -

-------------------------------------------------------------------------------
11/11/15 19:57:29 - Process(39916.4) User(mqm) Program(amqrmppa)
                    Host(nemdemo.uk.ibm.com) Installation(Installation1)
                    VRMF(8.0.0.0) QMgr(TESTQM)
                   
AMQ9660: SSL key repository: password stash file absent or unusable.

EXPLANATION:
The SSL key repository cannot be used because MQ cannot obtain a password to
access it. Reasons giving rise to this error include: 
(a) the key database file and password stash file are not present in the
  location configured for the key repository, 
(b) the key database file exists in the correct place but that no password
  stash file has been created for it, 
(c) the files are present in the correct place but the userid under which MQ is
  running does not have permission to read them, 
(d) one or both of the files are corrupt. 

The channel is '????'; in some cases its name cannot be determined and so is
shown as '????'. The channel did not start.
ACTION:
Ensure that the key repository variable is set to where the key database file
is. Ensure that a password stash file has been associated with the key database
file in the same directory, and that the userid under which MQ is running has
read access to both files. If both are already present and readable in the
correct place, delete and recreate them. Restart the channel.


I also noticed that WAS returned: -

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

     Caused by [2] --> Message : com.ibm.mq.jmqi.JmqiException: CC=2;RC=2397;AMQ9204: Connection to host 'nemdemo.uk.ibm.com(1420)' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2397;AMQ9771: SSL handshake failed. [1=javax.net.ssl.SSLHandshakeException[Remote host closed connection during handshake],3=nemdemo.uk.ibm.com/192.168.1.113:1420 (nemdemo.uk.ibm.com),4=SSLSocket.startHandshake,5=default]],3=nemdemo.uk.ibm.com(1420),5=RemoteTCPConnection.protocolConnect]

     Caused by [3] --> Message : com.ibm.mq.jmqi.JmqiException: CC=2;RC=2397;AMQ9771: SSL handshake failed. [1=javax.net.ssl.SSLHandshakeException[Remote host closed connection during handshake],3=nemdemo.uk.ibm.com/192.168.1.113:1420 (nemdemo.uk.ibm.com),4=SSLSocket.startHandshake,5=default]

     Caused by [4] --> Message : javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake

     Caused by [5] --> Message : java.io.EOFException: SSL peer shut down incorrectly

This all occurred as soon as I started the MDB.

The connectivity between WAS and MQ is encrypted using a CA-signed certificate, over a TLS 1.2 connection.

I had previously set up my Queue Manager to use TLS: -

echo "ALTER QMGR SSLKEYR('"/home/mqm/SSL/keystore.kdb"')" | runmqsc TESTQM
echo "DIS QMGR SSLKEYR" | runmqsc TESTQM
echo "REFRESH SECURITY TYPE(SSL)" | runmqsc TESTQM


and my Server Connection Channel to use a specific cipher: -

echo "DEFINE CHANNEL("TEST.QMGR.SVRCONN") CHLTYPE(SVRCONN) SSLCIPH("TLS_RSA_WITH_AES_128_CBC_SHA256") REPLACE" | runmqsc TESTQM
echo "ALTER CHANNEL("TEST.QMGR.SVRCONN") CHLTYPE(SVRCONN) SSLCAUTH(OPTIONAL)" | runmqsc TESTQM


Reading the message explanation above, I spent time looking at the key store / stashed password etc.

ls -al /home/mqm/SSL/

total 28
drwxrwxr-x  2 mqm mqm  4096 Nov 11 13:02 .
drwx------. 4 mqm mqm  4096 Nov 11 19:02 ..
-rwxrwxrwx  1 mqm mqm 10080 Nov 11 15:11 keystore.kdb
-rwxrwxrwx  1 mqm mqm    80 Nov 11 15:11 keystore.rdb
-rwxrwxrwx  1 mqm mqm   129 Nov 11 15:11 keystore.sth

checking that the MQ user mqm had full access to the key store.

I also checked that the stashed password worked OK: -

runmqakm -cert -list -db /home/mqm/SSL/keystore.kdb -stashed

Certificates found
* default, - personal, ! trusted, # secret key
! "CN=uk-WIN-AJ9S32NP29C-CA, DC=uk, DC=ibm, DC=com"
*- nemdemo.uk.ibm.com

so that ruled that one out.

I then read a few IBM PMRs and found a potential hint, suggesting that the extension of the keystore database, as defined in the Queue Manager, does NOT need to be specified.

I updated the Queue Manager configuration: -

echo "ALTER QMGR SSLKEYR('/home/mqm/SSL/keystore')" | runmqsc TESTQM
echo "REFRESH SECURITY TYPE(SSL)" | runmqsc TESTQM

and, guess what, it worked :-)

Note to self - Firefox and local connections

 Whilst trying to hit my NAS from Firefox on my Mac, I kept seeing errors such as:- Unable to connect Firefox can’t establish a connection t...