Skip to main content

Musings on SSL troubles in websphere container

SSL is a standard technology for connecting systems in a client server architecture.

Setting up our Java based applications to use SSL requires setting up keystores and truststores. Java provides a key and certificate management utility called keytool that can be used to setup required key and trust-stores for secure communication.

With websphere, things get a little different.

  • Websphere provides a tool called ikeyman that is used to manage key and trust databases.
  • The JEE container loads the SocketFactory, that an application can refer using SSLSocketFactory.getDefault(), with the certificates from the key and trust databases.
  • The default instance of SSLSocketFactory does not load certificates that might be present in the JRE.

This brings us to a major consideration while working with SSL on websphere. Work only with default SSLSocketFactory. APIs not using default SSLSocketFactory will not work, unless we write code that handles the certificates and sets up SSLSocketFactory to be used.
For example, CXF does not use default SSLSocketFactory unless configured so. It requires setting useHttpsURLConnectionDefaultSslSocketFactory. Refer CXF TLS Config.

But handling certificates ourselves can have unwanted consequences too. A lot of effort goes into troubleshooting when a new third party API (for example, MS Exchange webservices Java API) is added to an application that causes all SSL interactions to fail, while the new API works just fine. It is attributed to the fact that the new API, we added, changed the default SSLSocketFactory in HTTPSURLConnection to a different instance. In such cases, we'd need to modify the API to use default SSLSocketFactory and not change it.

Comments

Popular posts from this blog

Catch hold of that Exception and hide that stacktrace!!!

E xceptions happen!!! Rules are to be followed, too. Time and again, Java developers are told the golden rule to catch specific exceptions and not to catch the generic Exception. The thought process behind that is, applications should not catch runtime exceptions. This is apt as runtime exceptions are an indicator of "bugs" in the code. However, blindly following rules, as always, can have unexpected consequences. If you are developing services that are to be exposed over the wire, it is always a good idea to break this rule and "catch that Exception". Instead, follow the below principles: Service methods should implement a generic Exception block, along with catching declared exceptions, thrown from inner layers of the code.  If needed, the service can throw another exception back to the client. What's important is that we create a new Exception instance to be thrown, along with relevant message for the client. The service can log stacktrace for the E...

Using JNDI managed JMS objects with Apache CAMEL

Apache CAMEL uses Spring JMS to work with JMS Queues or Topics. Evidently, we will need Spring to configure and use JMS capabilities provided by CAMEL. Details about how to implement JMS based routes using Apache CAMEL can be found in the CAMEL documentation. However, the documentation leaves a lot to be figured out. In a typical Java EE container, it is usually a good idea to abstract the underlying JMS resources by using JNDI. We can use the below configuration to achieve that. This configuration is tested in Websphere environment, but should work in any JEE container. Create a JMS queue connection factory in the JNDI registry. CAMEL configuration will be able to use only one queue connection factory, even if we have more than one. Create one or more JMS queue or topics, in the JNDI registry, as required. The above two steps are related to generic JNDI configuration for JMS resources. Now we come to the setup required for making these JMS resources work with CAMEL rout...

Cassandra data modelling: Redundant data, a tough decision

The biggest challenge around building an efficient data model for Cassandra is data redundancy. Though the basic rules for data modelling with Cassandra, mention the usual RDBMS modelling goals, as non goals for Cassandra (Refer:  Basic rules for C* data modelling ), it builds upon assumptions that clusters are built on commodity hardware, storage is cheap, and as data needs increase more nodes can be added to the cluster incurring very low cost. But in real life we are faced with technical as well as non technical problems. a. Keeping multiple column families in sync can be a major overhead, if the same data is spread across them. What if writes to some CF succeed and some fail? How long and how much will we retry? b. Horizontal scalability may be a truth, but think of a mundane question of where to keep all those heat producing, energy guzzling machines? So how do we model the database that does not allow joins without redundancy? The simple answer is, we do not. Wh...