# mbedTLS integration

**URL:** <https://mangoh.discourse.group/t/mbedtls-integration/978>\
**Category:** mangOH Red\
**Created:** [December 8, 2017, 12:39pm UTC](https://mangoh.discourse.group/t/mbedtls-integration/978 "2017-12-08T12:39:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![munirchowdhury](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@munirchowdhury](https://mangoh.discourse.group/u/munirchowdhury)\
**Post date:** [December 8, 2017, 12:39pm UTC](https://mangoh.discourse.group/t/mbedtls-integration/978/1 "2017-12-08T12:39:18Z")

</div>

Does any have experience of integrating the mbedTLS into MQTT broker?

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [December 8, 2017, 3:31pm UTC](https://mangoh.discourse.group/t/mbedtls-integration/978/2 "2017-12-08T15:31:52Z")

</div>

Are you trying to run a broker on the mangOH Red? If so, what are your clients?

---

<div class="post-metadata">

**Author:** ![munirchowdhury](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@munirchowdhury](https://mangoh.discourse.group/u/munirchowdhury)\
**Post date:** [December 9, 2017, 8:57pm UTC](https://mangoh.discourse.group/t/mbedtls-integration/978/3 "2017-12-09T20:57:57Z")

</div>

I’m trying too bind the dataconnectionservice and modem service but stumped at the moment as the data structures don’t align

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [December 9, 2017, 9:14pm UTC](https://mangoh.discourse.group/t/mbedtls-integration/978/4 "2017-12-09T21:14:05Z")

</div>

Can you provide an example of the issue you are having.

---

<div class="post-metadata">

**Author:** ![munirchowdhury](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@munirchowdhury](https://mangoh.discourse.group/u/munirchowdhury)\
**Post date:** [December 9, 2017, 9:43pm UTC](https://mangoh.discourse.group/t/mbedtls-integration/978/5 "2017-12-09T21:43:15Z")

</div>

I notice that [https://github.com/startwithsierra/utils-legato-mqtt](https://github.com/startwithsierra/utils-legato-mqtt) doesn’t have any TLS support so I I am attempting to integrate from [https://github.com/ARMmbed/mbedtls](https://github.com/ARMmbed/mbedtls). I don’t understand the network interface of the mbed well enough to know if its possible to send the data on the WP85’s cellular modem. I can’t see lower down in either APIs to know whether I can do a binding of dataconnectionservice’s read, write, connect, disconnect to the equivalent mbedtls’s network structure

---

<div class="post-metadata">

**Author:** ![munirchowdhury](https://avatars.discourse-cdn.com/v4/letter/m/f6c823/32.png) [@munirchowdhury](https://mangoh.discourse.group/u/munirchowdhury)\
**Post date:** [December 10, 2017, 11:29am UTC](https://mangoh.discourse.group/t/mbedtls-integration/978/6 "2017-12-10T11:29:28Z")

</div>

Hi I had a look at your Paho Linux Version. Encouraged by the direction that you’re taking it with the certificate support and also with the non-dependency on the closed datarouter. That datarouter is horrible.

A few questions on your implementation though,

I ran a doxygen and couldn’t trace the details of certain functions like MQTTClient\_connect, MQTTClient\_disconnect, and MQTTClient\_publish

or the full structure definitions  
typedef struct mqtt\_Session  
{  
MQTTClient client;  
MQTTClient\_connectOptions connectOptions;  
MQTTClient\_SSLOptions sslOptions;  
mqtt\_MessageArrivedHandlerFunc\_t messageArrivedHandler;  
void\* messageArrivedHandlerContext;  
mqtt\_ConnectionLostHandlerFunc\_t connectionLostHandler;  
void\* connectionLostHandlerContext;  
// The legato client session that owns this MQTT session  
le\_msg\_SessionRef\_t clientSession;  
} mqtt\_Session;

Where would these be defined?

Also I notice you have implemented support for root CA. How could I include support for the client certificate and private key?

Whether its your implementation or the mbedLTS/AWS (which is also based on the Paho Linux implementation), since neither can use the existing datarouter (and in its current implementaion it shouldn’t), my question remains the same as above - how to open a socket connection and bind it to the mqtt services. People I know who have used the SW HL series have used the AT command set to establish data connections. I have no expertise in that area so an API solution would be ideal. Any suggestions welcome.

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [December 12, 2017, 5:36pm UTC](https://mangoh.discourse.group/t/mbedtls-integration/978/7 "2017-12-12T17:36:35Z")

</div>

Adding support for client certificates is on my personal TODO list, but I have some higher priority tasks, so I doubt I will get to it in the near future. I haven’t been using doxygen, so I can’t comment on how the output looks.

`MQTTClient_connect()` is part of paho. It’s defined in `pahoLegatoComponent/paho.mqtt.c/src/MQTTClient.c` at line 1153.

If you’re interested in adding support for client certificates, then the place to look is the parameters set in the `sslOptsions` member of the `mqtt_Session` struct that you mentioned in your previous post. Patches are welcome 🙂
