This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

MQTT integration with Losant IoT

Good afternoon,

First of all, I hope that you are all well and are able to work from home, regardless of the government instructions of your country of residence.

My question is related to an experiment we are currently running using the Losant IoT platform (https://app.losant.com) and several Nordic Thingy:52 kits.

We have already managed to connect a kit to Losant using a Raspberry Pi3 as a gateway. However, it is important to our experiment to connect a different kit to Losant IoT using a different method, namely an MQTT integration.

In order to achieve an MQTT integration with Losant, which we have successfully achieved using other sensors from other brands, Losant requires the following data (also including our current inputs):


MQTT
a2n7tk1kp18wix-ats.iot.us-east-1.amazonaws.com

PORT
8883

CLIENT ID
prod-4c2698a1-2597-4760-82d1-7ecf1be56d18-account

AUTHENTICATION

Private Key
-----BEGIN RSA PRIVATE KEY-----{Private key}-----END RSA PRIVATE KEY-----

Certificate
-----BEGIN CERTIFICATE-----{Certificate}-----END CERTIFICATE-----

TOPICS

prod/4c2698a1-2597-4760-82d1-7ecf1be56d18/a/gateways
prod/4c2698a1-2597-4760-82d1-7ecf1be56d18/a/connections
prod/4c2698a1-2597-4760-82d1-7ecf1be56d18/a/alerts
prod/4c2698a1-2597-4760-82d1-7ecf1be56d18/a/alerts/notifications
prod/4c2698a1-2597-4760-82d1-7ecf1be56d18/m/

CA CERTIFICATE

-----BEGIN CERTIFICATE-----{CA Certificate}-----END CERTIFICATE-----

Even though we succesfully connected the kit to nrfcloud using an iOS device as gateway and are able to follow the MQTT documentation instruction to obtain the above data for our inputs (I have attached the JSON response to the POST API call to certificate as described in the MQTT documentation, as well as the certificate downloaded from nrfcloud), when using this data in Losant IoT we keep receiving the following error message:

Failed to create integration!
Invalid openssl exit code: 1 % openssl x509 -noout -nameopt RFC2253,sep_multiline,space_eq,-esc_msb,utf8 -text -in /tmp/3a40d58688868c30f5e7e2bea98a5119ab6df832 unable to load certificate 140522648251720:error:0909006C:PEM routines:get_name:no start line:crypto/pem/pem_lib.c:745:Expecting: TRUSTED CERTIFICATE

Can you provide any help or guidance in order to get past this step? What could be going wrong? Did we miss any steps?

Thank you in advance, stay safe!

Parents
  • Hi.

    First of all, you should never post your certificates, and especially not your private key. Especially not in a public ticket.

    You can upload json files by zipping them first, then upload the zipped file/folder.

    When it comes to your actual problem, I am not quite sure I understand what your problem is.

    What does the nRF Cloud certificates have to do Losant?

    What file are you (or the library/script) provide to openssl? Is the file in the expected format?

    Best regards,

    Didrik

Reply
  • Hi.

    First of all, you should never post your certificates, and especially not your private key. Especially not in a public ticket.

    You can upload json files by zipping them first, then upload the zipped file/folder.

    When it comes to your actual problem, I am not quite sure I understand what your problem is.

    What does the nRF Cloud certificates have to do Losant?

    What file are you (or the library/script) provide to openssl? Is the file in the expected format?

    Best regards,

    Didrik

Children
  • Thank you for your prompt reply Didrik. I have now edited my original post to remove all certificate and private key information.

    I will try to rephrase my question in order to give you a better understanding of the problem.

    In order to setup an integration on the Losant IoT platform, a specific set of information has to be provided, as detailed in the relevant documentation: https://docs.losant.com/applications/integrations/

    I have already followed these instructions to successfully subscribe to another MQTT stream setup by my colleagues using a different set of sensors.

    By following these instructions and the relevant MQTT documentation of the nrfcloud.com platform, I believe I am supplying the appropriate information to Losant in order to create the MQTT subscription (i.e. make Losant subscribe to the MQTT stream setup by nrfcloud.com).

    Is that accurate and feasible? Isn't nrfcloud.com creating an MQTT stream when a Thingy:52 is connected to it via a gateway (my iOS device in this instance)? Am I missing some step and receiving the error message from Losant as a result?

  • Ok, I think I understand what you mean now.

    As for the error you get, how did you provide the certificates to the integration script?

    You have to replace the \n escape characters with actual newlines for the keys to be "proper" .pem keys. One quick way to do this is to save the downloaded json as a file, then use the "Link Monitor" application in nRF Connect for Desktop, switch to the "Certificate manager" tab, and load the certificates from the json file.

  • I just copied and pasted the certificate and key text, including the \n escape characters, which might as well be the cause of the error message.

    Will follow your suggestion and post back my findings.

    Thank you once again Didrik, stay safe!

Related