Securely connecting to Solace Cloud  from Boomi
Tags: ipaas, boomi, solace, eventdriven
Published: 2021-02-09 17:25:28

So you followed the "Getting started with Boomi and Solace" tutorial or played with the "Solace PubSub+ Connector" in your Boomi account.
Everything is great - you can connect, produce and consume events using the PubSub+ cloud service.

(Note - for the rest of this article we assume you have a Connection to Solace defined in your Boomi workspace, e.g. because you followed the tutorial above)

But hang on - in the tutorial you used a plain TCP socket to connect to PubSub+. Wouldn't it be better to use TLS encryption?

That's when you look at your PubSub+ Service in Solace Cloud and discover there's a TLS encrypted endpoint - labelled "Secured SMF Host". This should be easy - just use the secure endpoint and you're done? Right?
![image](https://dev-to-uploads.s3.amazonaws.com/i/17svle1fi9nabeu8xj40.png)
 
Well it isn't otherwise I wouldn't have written this post.

Next you replaced the plain TCP connection URL with the secured URL (as I did in the screenshot below). Then you tested the connection again using the handy "Test Connection" button in the Boomi Connection Setup dialog. 

Looks good, right?
![image](https://dev-to-uploads.s3.amazonaws.com/i/92eim3j5ks43tq92rp1m.png)
Oh no, not if you are using a cloud hosted Atom!
![image](https://dev-to-uploads.s3.amazonaws.com/i/39y442p48p1j1lia7bcw.png)

As you can see the Connector tries to use the default Java trust store so it can verify the certificate presented by the PubSub+ service. And for good reason this access isn't allowed in the cloud.

How do we fix this?
- we will need to obtain or create a suitable trust store
- we will need to make the trust store available on the Atom
- then tell the connector to use it.

Luckily we can do this. Let's look at these steps.

## Obtain a suitable Trust Store

PubSub+ Cloud services use a certificate signed by Digicert. The standard Java trust store includes the Root CA certificate.
You have two options here:
- the easy way
- the hard way

Let's do easy first - as you can see the Connector attempts to use `cacerts`. This is included in all Java installations - chances are high you have a few copies on your hard disk already. So just do a search and grab one of these. You can also obtain a copy from the OpenJDK repository - e.g. [here](http://hg.openjdk.java.net/jdk/jdk/raw-file/76072a077ee1/src/java.base/share/lib/security/cacerts).

If you wanted to make the effort to create a trust store with only the Root CA required by the Connector to connect to Solace Cloud there's always the hard way.

First you need to download the root certificate from the Solace Cloud console in PEM format:
![image](https://dev-to-uploads.s3.amazonaws.com/i/w946ahlovd4792ezg3cn.png)
Java requires the trust store in a Java Keystore format. To create the trust store in the required format you can follow steps 1 to 6 in [Converting PEM-format keys to JKS format](https://docs.oracle.com/cd/E35976_01/server.740/es_admin/src/tadm_ssl_convert_pem_to_jks.html).
In the following screenshots I used the easy way, just replace `cacerts` where ever you see it with the name of your trust store if you did it the hard way. 

## Uploading the Trust Store to Boomi Atom(s)

Now you have a trust store, how do you deploy it to your Boomi environment?
There are [multiple folders](https://community.boomi.com/s/article/atominstallationdirectoryreference) that a Boomi process has access to.
From that list the `work` and the `userlib` location stood out to me. Any process can write into the work directory so that may be an option, but although it is marked as "Permanent" storage it reads like it's  intended for temporary storage. The other folder - userlib - is used to store "Custom Libraries". These are a way to add additional Java libraries to a Boomi environment. It goes through the same packaging, versioning and deployment cycle as Boomi processes themselves.
Sounds like a good way to manage the rollout of our trust store.

The steps to do this are:
- Upload the trust store to the [Account Library](https://help.boomi.com/bundle/integration/page/r-atm-Account_Library_Management.html) in your Boomi account
- Create and deploy a [Custom Library](https://help.boomi.com/bundle/integration/page/c-atm-Custom_Library_components.html)
-Verify the trust store was uploaded to your Atom(s)

I'll add some key screen shots below, detailed instructions can be found in the links.

Here's how you add the "Account Library". Note that you are only allowed to upload JAR files - you need to add the `.jar` extension to your trust store's file name. I have renamed mine to `cacerts.jar`
![image](https://dev-to-uploads.s3.amazonaws.com/i/bvdvngtg6w8dj2c5bn8d.png)
Then create the "Custom Library", here's a screen shot how you do that. Also the library I have created is in the background, note how I added the `cacerts.jar` in there:
![image](https://dev-to-uploads.s3.amazonaws.com/i/dwjwra2on8zyhkibn3nt.png)

If you prefer - when creating the custom library you can choose to associate it with the Connector by setting the library type to "Connector" and connector type to "PubSub+ Connector". This will put the trust store in a dedicated sub-directory of `userlib`
![image](https://dev-to-uploads.s3.amazonaws.com/i/9lw01ns4npsx9b9dre7l.png)
 
You then create a "Packaged Component" and deploy it to your environment, I'll skip this here and fast forward to the result, the library was applied to the Atom:
![image](https://dev-to-uploads.s3.amazonaws.com/i/ow6ph2eqppbmo0plyu1z.png)

And here is what it looks like if you set the Custom Library type to "Connector", note the sub directory that was created in `userlib`.
![image](https://dev-to-uploads.s3.amazonaws.com/i/x2xcg5ikqv2so6ler8fr.png)
 
## Set Trust Store used by the Connector

The last step is to let the Connector know to use our trust store.
This is where the "Custom Properties" come into play. There is a property `SSL_TRUST_STORE` we can set and we point that to the file that was uploaded - remember it's in the `userlib` directory
![image](https://dev-to-uploads.s3.amazonaws.com/i/b12d2pmf33nmrcccp0zt.png)

If you selected "Connector" as Custom Library Type the trust store will be located in a sub directory of userlib - you can look up the location in the Atom Management - see the screen shot in the preceding section.
![image](https://dev-to-uploads.s3.amazonaws.com/i/hdzvtriist488mtt0c3e.png)
 
There's some information on these "Custom Properties" in the [Connector's documentation](https://help.boomi.com/bundle/connectors/page/int-Solace_PubSub_connection.html) and a guide on the properties you can use in the [Solace API documentation](https://docs.solace.com/API-Developer-Online-Ref-Documentation/java/com/solacesystems/jcsmp/JCSMPProperties.html).

Now try "Test Connection" again, select an Atom in the Environment that you applied the "Custom Library" to and ...
![image](https://dev-to-uploads.s3.amazonaws.com/i/fqdnrqy695bz4xeuhbpw.png)