---
title: Generic MQTT Over SSL Using Mosquitto
slug: bhdo/generic-mqtt-over-ssl-using-mosquitto
createdAt: 2022-11-24T20:42:44.000Z
---

You can connect and send messages to an outside message broker from a generic MQTT-Over SSL message broker.

Mosquitto is a lightweight open source message broker that Implements MQTT versions 3.1.0, 3.1.1 and version 5.0. It is written in C by Roger Light, and is available as a free download for Windows and Linux and is an Eclipse project.

In the following use case, the Mosquitto MQTT Broker on Ubuntu is already installed.

The connection details are the same ones used during the installation for Mosquitto MQTT Broker on Ubuntu.

# Before You Begin

Make sure you [Install the Mosquitto MQTT Broker on Ubuntu](https://public-docs.litmus.io/bhdo/install-the-mosquitto-mqtt-broker-on-ubuntu).&#x20;

# Step 1: Retrieve Contents of ca.crt File

You will need to retrieve the contents of the ca.crt file, so that you can add it to the CA Certificate parameter value in the connector you'll configure in Step 2. &#x20;

**To retrieve the contents of the ca.crt file:**

1. Go to the Ubuntu system.
2. Open your **Home&#xA0;**&#x64;irectory using the *Files&#x20;*&#x61;pp.
3. Open the **ca.crt** file.
4. If you see the message *Could Not Display "ca.crt"*, click **Cancel**.
5. Right-click the **ca.crt** file and select **Open with Other Application**.
6. Select **View All Applications**.
7. Select **Text Editor&#xA0;**&#x61;nd click **Select**.
8. Copy the entire contents of the file.

# Step 2: Add Generic MQTT Over SSL Connector

Follow the steps to [Add a Connector](https://public-docs.litmus.io/bhdo/add-a-connector) and select the **MQTT - Generic over SSL&#x20;**&#x70;rovider.&#x20;

Configure the following parameters.&#x20;

- **Name**: A recognizable name to identify the connector.&#x20;
- **Hostname**: Since Mosquitto is running locally on your PC, enter your IP address.
- **Port**: Confirm that the default value **8883** is entered.&#x20;
- **CA Certificate**: Paste the ca.crt file you copied in Step 1.&#x20;
- **Certificate&#x20;**(Optional)
- **Private key&#x20;**(Optional)
- **Client ID**: Enter **\<username>-with-ssl**.&#x20;
- **Username&#x20;**(Optional)
- **Password&#x20;**(Optional)
- **QoS**: Confirm that the default value **0** is entered. The Quality of Service (QoS) level is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message.
- **Parallel Publish Count**: Confirm that the default value of **100&#x20;**&#x69;s entered. The number of messages being published simultaneously. Once the defined limit has been reached, subsequent messages are silently dropped.&#x20;
- **Integration Topic**: Enter **test**.&#x20;
- **LWT topic**: Enter **lwtTopicName**.&#x20;
- **LWT payload**: Enter **Some LWT Payload**.&#x20;
- **LWT payload type**: The payload type for MQTT's Last Will and Testament feature. The options are *string&#x20;*&#x61;nd *base64*.&#x20;
- **LWT QoS**: The Quality of Service value for MQTT's Last Will and Testament feature.
- **LWT retained**: Select this check box to retain the value for MQTT's Last Will and Testament feature.&#x20;
- **Throttling limit**: The maximum number of messages per second to be processed. The default value is zero, which means that there is no limit.&#x20;
- **Persistent storage**: When enabled, this will cause messages to undergo a store-and-forward procedure. Messages will be stored within Belden Horizon Data Operations when cloud providers are online. &#x20;

# Step 3: Observe the Log File

**To observe the log file:&#x20;**

1. Return to the Ubuntu system.
2. Open a Terminal window if none is open.
3. Enter `sudo tail -f /var/log/mosquitto/mosquitto.log` and press **ENTER&#xA0;**&#x74;o open the log file.
4. View the incoming requests.

# Step 4: Enable MQTT Over SSL Connector

**To enable the connector:&#x20;**

1. Return to the *Belden Horizon Data Operations Integration* browser tab.
2. Click the connection toggle on the connector tile.&#x20;
   The connector shows connected after verifying the connection.

   ::Image[]{src="https://api.archbee.com/api/optimize/SSUUxKZUk9bFTEPNn_6Zo/L6lpKSf8YznYGaSENk12b_mqttgenericssl.png" size="60" width="354" height="262" caption="Toggle to enable connector" position="center" showCaption="true"}

# Step 5: View the Connection in the Log File

**To view the connection in the log file:&#x20;**

1. Return to the Ubuntu system log file.
2. Enter `sudo tail -f /var/log/mosquitto/mosquitto.log`.
   The log file shows the new connection.&#x20;

You should see something like this:

:::BlockQuote
1576338704: New connection from 192.168.1.15 on port 8883.

1576338704: New client connected from 192.168.1.15 as JohnSmith-with-SSL (p2, c1, k2, u'JohnSmith').
:::

