How to connect to an email server using TLSv1.2 from BusinessWorks and BusinessWorks Container Edition

Emmanuel Marchiset
5 min readOct 10, 2023

--

Security is more and more a concern in integration projects and this includes securing the connections to the enterprise email server.

This article explains how to connect to an SMTP email server using TLS 1.2 from BusinessWorks and BusinessWorks Container Edition, this is illustrated in the article by the set-up of a connection to the Microsoft outlook.com email cloud service that is using TLSv1.2.

Pre-requisites

You need to have the public certificates of the target SMTP server in a common format (for example .crt or .cer files).

You need to know the hostname and port used by the target email server.

For outlook.com the host and port to use are the following: smtp-mail.outlook.com:587

Reference elements are available on the Microsoft support site:

https://support.microsoft.com/fr-fr/office/param%C3%A8tres-pop-imap-et-smtp-pour-outlook-com-d088b986-291d-42b8-9564-9c414e2aa040

Downloading the outlook.com public certificates

To do this you need to use opensll, the Windows version of this open source tool can be downloaded from the following URL:

https://slproweb.com/products/Win32OpenSSL.html

Once installed you have to use the following command to get the certificates:

openssl s_client -starttls smtp -showcerts -connect smtp-mail.outlook.com:587

openssl command to get the certificates from the email server

From the output of the command you can just copy / paste certificates to a text file using the .crt extension one by one (make sure to have one text file per certificate and to include the ‘BEGIN CERTIFICATE’ and ‘END CERTIFICATE’ tags as shown below).

Output of the openssl command, the highlighted area shows the selection to use to extract a certificate

Keep the certificate files in a local folder on your machine.

Example on how the certificates folder content should look like:

Certificates used to connect to the outlook.com service

Creating a keystore file

This can be done with the Key Store Explorer tool available at the following URL: https://keystore-explorer.org/

With Key Store Explorer you have to do the following:

. Import the certificates, this can be done with the ‘Examine -> Examine File’ menu

Loading a certificate file from Key Store Explorer

. Once a file is opened the corresponding certificate can be imported, using the ‘Import’ button

Importing a certificate file from Key Store Explorer

When asked to create a new KeyStore select the Key Store type and click OK

Selecting the Key Store type in Key Store Explorer

Then accept the default certificate alias:

Accepting the default Alias in Key Store Explorer

. Once done with all the certificates save the KeyStore file

Example Key Store file containing the outlook.com certificates

You will have to set a password and enter the target file name.

Keep the keystore file path and password for later use.

Updating the application

You have to do the following:

. Create the properties needed to configure an SMTP Connection resource

Properties needed to configure the SMTP Connection resource

. Create properties needed to configure a Key Store Configuration resource

Properties needed to configure the Key Store Configuration

. Create a Key Store Configuration resource

The resource has to be configured with:

  • The path to the target keystore file
  • The type of the keystore file
  • The password of the target keystore file
Example of a Key Store Configuration resource

. Create an SSL Client Configuration resource

The resource has to be configured with:

  • The reference to the Trust Store resource
  • The target encryption protocol (it is generally recommended to use TLS 1.2 at a minimum)

It is a good practice to use ciphers using at least 256 bit encryption.

Example of an SSL Client Configuration resource

. Create an SMTP Connection shared resource

The following configuration parameters can be set using the properties previously created:

  • Machine Name
  • Port
  • Username
  • Password

When connecting to outlook.com or a Microsoft Exchange server make sure to check the ‘Enable STARTTLS’ option.

Then check the ‘Confidentiality’ option and select the SSL Client Configuration resource previously created.

Example of an SMTP Resource resource

. Then the ‘Send Mail’ activity must be configured with the following:

  • In the ‘General’ tab select the SMTP Configuration resource previously created:
Example of a Send Mail activity General configuration
  • In the ‘Input’ tab map the input fields as needed :
Example of a Send Mail activity Input mappings

Testing the application in the Debugger

The application can then be tested in the Studio Debugger.

In case of problems you can add the following property in the JVM Arguments:

-Djavax.net.debug=ssl,handshake,plaintext,record

This can be done in the ‘Arguments’ tab of the Run -> Debug Configuration panel :

SSL debug properties set in the JVM Arguments tab of the Debug Configuration panel

With this option the SSL/TLS negociation messages will be logged in the Designer Console Window.

You may also have a look the following TIBCO support KB article:
https://community.tibco.com/s/article/common-errors-tibco-activematrix-businessworkstm-related-ssl-communication

Using the certificates in deployed mode

You have to do the following:

. Copy the certificate files to the target BusinessWorks servers

. Set the application properties according to the target environment

Integration with a Microsoft Exchange server

With the elements above you should be able to connect to an on-premises Microsoft Exchange Server. In such configuration you need to use the public certificates of the target Microsoft Exchange Server.

--

--

Emmanuel Marchiset
Emmanuel Marchiset

Written by Emmanuel Marchiset

I work as an Architect at TIBCO Software on Integration products. Opinions here are my own.

No responses yet