<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Connecting device to AWS IoT Core (aws_fota)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53107/connecting-device-to-aws-iot-core-aws_fota</link><description>I&amp;#39;ve been trying to connect my device to AWS IoT for a week, but I&amp;#39;m getting the same error &amp;quot;no matter what&amp;quot; I do (ERROR: mqtt_connect -45), which seemingly is an authorization issue of some kind? 
 Here are the exact steps I&amp;#39;m doing to connect my device</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 12 Oct 2019 19:20:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53107/connecting-device-to-aws-iot-core-aws_fota" /><item><title>RE: Connecting device to AWS IoT Core (aws_fota)</title><link>https://devzone.nordicsemi.com/thread/214679?ContentTypeID=1</link><pubDate>Sat, 12 Oct 2019 19:20:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ba8b681-aa73-40bc-ad01-e6e79a42faa5</guid><dc:creator>sigvartmh</dc:creator><description>&lt;p&gt;I&amp;#39;m a bit out of ideas then, if the &lt;strong&gt;port&lt;/strong&gt;, &lt;strong&gt;host&lt;/strong&gt;, &lt;strong&gt;clientId&lt;/strong&gt;, and &lt;strong&gt;certificates&lt;/strong&gt; worked with the IoT SDK, it means that your AWS IoT setup is correct, so that leaves only the setup on the device. So I would make sure the client ID, host, and certificates are correctly setup on the device.&lt;br /&gt;&lt;br /&gt;It could still be a certificate error. Not getting&amp;nbsp;&lt;span&gt;-45&amp;nbsp;only means that the input is valid, meaning you stored&amp;nbsp;something that looks like a CA&amp;nbsp;in the CA slot in the modem (same goes for the rest). Unfortunately, it can&amp;#39;t tell you if what you are given is more than a valid cert. So the&amp;nbsp;&lt;strong&gt;&lt;span class="pl-en"&gt;ECONNREFUSED&lt;/span&gt;&lt;/strong&gt;&amp;nbsp;&lt;span class="pl-c1"&gt;61 could mean that the certificates contain some information that the server did not expect, meaning the one/some of the certificates could have been mangled in the certificates.h file when you wrote them to the modem. I recommend maybe trying to ensure the formating and that no extra characters have been added to it.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting device to AWS IoT Core (aws_fota)</title><link>https://devzone.nordicsemi.com/thread/214671?ContentTypeID=1</link><pubDate>Sat, 12 Oct 2019 13:20:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df44f5a1-d1b9-4a10-a959-483ce58a3a3e</guid><dc:creator>staklau</dc:creator><description>&lt;p&gt;Just tried connecting with the DeviceClass example for JS&amp;nbsp;&lt;a href="https://github.com/aws/aws-iot-device-sdk-js"&gt;https://github.com/aws/aws-iot-device-sdk-js&lt;/a&gt;&amp;nbsp;and it worked like a charm. Both publishing and receiving messages.&lt;/p&gt;
&lt;p&gt;Can&amp;#39;t see that I&amp;#39;ve made any mistakes entering the information from the certificates either, as this would be the only logical point of failure as far as I know.&amp;nbsp;Not sure where to go from here...&lt;/p&gt;
&lt;p&gt;But maybe it&amp;#39;s not a certificate error, since the error code changed when I added the correct&amp;nbsp;public&amp;nbsp;certificate, instead of the public key earlier?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting device to AWS IoT Core (aws_fota)</title><link>https://devzone.nordicsemi.com/thread/214668?ContentTypeID=1</link><pubDate>Sat, 12 Oct 2019 12:45:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb409e48-6ac0-4d3e-91dd-6f823e0294e0</guid><dc:creator>sigvartmh</dc:creator><description>&lt;p&gt;Maybe&amp;nbsp;attach a policy&amp;nbsp;to your certificates which looks like this&amp;nbsp;&amp;nbsp;&lt;a href="https://raw.githubusercontent.com/nRFCloud/device-simulator-v2/saga/data/policy.json"&gt;https://raw.githubusercontent.com/nRFCloud/device-simulator-v2/saga/data/policy.json&lt;/a&gt;&amp;nbsp;could help.&lt;/p&gt;
&lt;p&gt;Also, double-check that&amp;nbsp;&lt;span&gt;Client Id&amp;nbsp;=&amp;nbsp;&lt;strong&gt;Thing name&lt;/strong&gt; and that your certificates are connected to that specific name. It could also be that you have malformed the certificates in the certificates.h file. It&amp;#39;s important to not add any additional information to the strings except \n. So you get something which looks like&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define MY_CERT \
&amp;quot;-----BEGIN RSA PRIVATE KEY-----\n&amp;quot;\
&amp;quot;CERT_DATA_BASE64_INFO_IS_HERE/DEADC0DEDEADC0DEDEADC0DE\n&amp;quot;\
&amp;quot;CERT_DATA_BASE64_INFO_IS_HERE/DEADC0DEDEADC0DEDEADC0DE\n&amp;quot;\
&amp;quot;CERT_DATA_BASE64_INFO_IS_HERE/DEADC0DEDEADC0DEDEADC0DE\n&amp;quot;\
&amp;quot;CERT_DATA_BASE64_INFO_IS_HERE/DEADC0DEDEADC0DEDEADC0DE\n&amp;quot;\
&amp;quot;CERT_DATA_BASE64_INFO_IS_HERE/DEADC0DEDEADC0DEDEADC0DE\n&amp;quot;\
&amp;quot;CERT_DATA_BASE64_INFO_IS_HERE/DEADC0DEDEADC0DEDEADC0DE\n&amp;quot;\
&amp;quot;CERT_DATA_BASE64_INFO_IS_HERE/DEADC0DEDEADC0DEDEADC0DE\n&amp;quot;\
&amp;quot;-----END RSA PRIVATE KEY-----\n&amp;quot;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If that does not work I would&amp;nbsp;try to&amp;nbsp;debug by testing that the&amp;nbsp;certificates&amp;nbsp;work with the AWS&amp;nbsp;Python SDK&amp;nbsp;&lt;a href="https://docs.aws.amazon.com/greengrass/latest/developerguide/IoT-SDK.html"&gt;https://docs.aws.amazon.com/greengrass/latest/developerguide/IoT-SDK.html&lt;/a&gt;&amp;nbsp;if you know python. They also have bindings for JS, Java, and C++ but the python and JS are the simplest ones to get up and running with certificates.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting device to AWS IoT Core (aws_fota)</title><link>https://devzone.nordicsemi.com/thread/214667?ContentTypeID=1</link><pubDate>Sat, 12 Oct 2019 12:35:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:63484e90-b569-4280-abc6-5164c940a070</guid><dc:creator>staklau</dc:creator><description>&lt;p&gt;The MQTT broker hostname was already found where you described. I tried&amp;nbsp;adding&amp;nbsp;it once more just to eliminate the&amp;nbsp;possibility&amp;nbsp;of typos, but I&amp;#39;m still getting the same errors. The correct port is 8883, right?&lt;/p&gt;
&lt;p&gt;Also when the thing was added to AWS IoT, a username and password was created, should these pieces of information be added somewhere, maybe?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting device to AWS IoT Core (aws_fota)</title><link>https://devzone.nordicsemi.com/thread/214665?ContentTypeID=1</link><pubDate>Sat, 12 Oct 2019 11:49:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62662514-2266-4da9-9350-f6b14992fff8</guid><dc:creator>sigvartmh</dc:creator><description>&lt;p&gt;What I tried to say is that you don&amp;#39;t need the&amp;nbsp;&lt;span&gt;CONFIG_NRF_CLOUD_PROVISION_CERTIFICATES&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;The error you get is described as&lt;/span&gt;&lt;span style="font-family:inherit;"&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;span class="pl-en" style="font-family:inherit;"&gt;ECONNREFUSED&lt;/span&gt;&lt;/strong&gt;&lt;span style="font-family:inherit;"&gt; &lt;/span&gt;&lt;span class="pl-c1" style="font-family:inherit;"&gt;61&lt;/span&gt;&lt;span style="font-family:inherit;"&gt; &lt;/span&gt;&lt;span class="pl-c" style="font-family:inherit;"&gt;/* Connection refused */ meaning the MQTT endpoint you tried to connect to refused your connection request. I would guess that what you&lt;/span&gt;&lt;span style="font-family:inherit;"&gt;&amp;nbsp;set as the AWS&amp;nbsp;IoT MQTT broker hostname is wrong. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;Not sure why you get -12 &lt;strong&gt;ENOMEM&lt;/strong&gt; but I assume it&amp;#39;s because&amp;nbsp;a resource is already in use and you can&amp;#39;t have 2 MQTT instances with TLS at the same as there is not enough memory on the device to handle it(&lt;strong&gt;This is just an assumption&lt;/strong&gt;)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I&amp;#39;ve found it easiest to find the &lt;strong&gt;host name&lt;/strong&gt; by going to the&lt;strong&gt; test panel&lt;/strong&gt; of the &lt;strong&gt;AWS IoT console.&lt;/strong&gt; Then &lt;strong&gt;click&lt;/strong&gt; on the name of the &lt;strong&gt;console&lt;/strong&gt; usually something like (&lt;span&gt;&lt;strong&gt;Connected as iotconsole-1570880786449-0&lt;/strong&gt;) and choose &lt;strong&gt;view endpoint&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting device to AWS IoT Core (aws_fota)</title><link>https://devzone.nordicsemi.com/thread/214664?ContentTypeID=1</link><pubDate>Sat, 12 Oct 2019 11:03:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4dce194d-9fc1-4dcd-9436-a723c40d7a34</guid><dc:creator>staklau</dc:creator><description>&lt;p&gt;Thank you for the answer, as suggested by &lt;a href="https://devzone.nordicsemi.com/members/sigvartmh"&gt;sigvartmh&lt;/a&gt; I used the provided certificate instead of the public key and the error disappeared. Now, however, I&amp;#39;m getting two new error codes&amp;nbsp;&lt;span&gt;&amp;quot;MQTT connect failed -61&amp;quot; and &amp;quot;ERROR: mqtt_connect -12&amp;quot;. Do you have any suggestions on what these error codes mean?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Both you and &lt;a href="https://devzone.nordicsemi.com/members/sigvartmh"&gt;sigvartmh&lt;/a&gt; have been referencing the&amp;nbsp;CONFIG_NRF_CLOUD_PROVISION_CERTIFICATES option, but this is not to be found in the sample. I am, however, seeing the&amp;nbsp;CONFIG_USE_PROVISIONED_CERTIFICATES option, is this the same as the&amp;nbsp;CONFIG_NRF_CLOUD_PROVISION_CERTIFICATES in previous versions of the sample, maybe?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting device to AWS IoT Core (aws_fota)</title><link>https://devzone.nordicsemi.com/thread/214663?ContentTypeID=1</link><pubDate>Sat, 12 Oct 2019 10:57:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc547def-30c8-4365-9a59-f6d7e930f0ae</guid><dc:creator>staklau</dc:creator><description>&lt;p&gt;Thank you for the in-depth answer, the problem was indeed that I was using the public key instead of the certificate. Now I am, however, receiving two more error codes&amp;nbsp;&lt;span&gt;&amp;quot;MQTT connect failed -61&amp;quot; and &amp;quot;ERROR: mqtt_connect -12&amp;quot; when I try to connect. Do you have any idea what the cause of this might be?&amp;nbsp;&lt;/span&gt;&lt;span&gt;I remember seeing a more descriptive list of the error codes somewhere, but I&amp;#39;m not able to find it again. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Also, I&amp;#39;m not sure if this is a version-thing, but the &amp;quot;CONFIG_NRF_CLOUD_PROVISION_CERTIFICATES&amp;quot; option is nowhere to be found in my sample (aws_fota v1.0.0), I only&amp;nbsp;find &amp;quot;CONFIG_USE_PROVISIONED_CERTIFICATES&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting device to AWS IoT Core (aws_fota)</title><link>https://devzone.nordicsemi.com/thread/214659?ContentTypeID=1</link><pubDate>Sat, 12 Oct 2019 10:10:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82b05381-9eb9-423b-bb9d-3f9621652dde</guid><dc:creator>sigvartmh</dc:creator><description>&lt;p&gt;The mqtt_connect: -45 by checking the &lt;a title="Error codes zephyr libc" href="https://github.com/NordicPlayground/fw-nrfconnect-zephyr/blob/6fb16c9686fd43cf2afddf21d48c196f245941c9/lib/libc/minimal/include/errno.h#L81" rel="noopener noreferrer" target="_blank"&gt;error codes&lt;/a&gt; means operation not supported on the socket. This is usually caused by a misconfiguration of the certificates which are provisioned.&lt;/p&gt;
&lt;p&gt;Unchecking&amp;nbsp;&lt;strong&gt;&lt;span&gt;Use provisioned certificates&lt;/span&gt;&lt;/strong&gt;&lt;span&gt; will provide certificates to the security tag selected in the Kconfig. I don&amp;#39;t think you need to&amp;nbsp;add the&amp;nbsp;CONFIG_NRF_CLOUD_PROVISION_CERTIFICATES=y option as this would be for the &lt;strong&gt;nRF Cloud&lt;/strong&gt; library.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;From what I can see from your post your problem is probably what you state here&amp;nbsp;&lt;span&gt;CLOUD_CLIENT_PUBLIC_CERTIFICATE is the&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;public key&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This is not your&amp;nbsp;&lt;strong&gt;public key,&lt;/strong&gt; but your&amp;nbsp;&lt;strong&gt;public certificate&lt;/strong&gt; from AWS, the file generated from AWS,&amp;nbsp;is usually formatted in the following form&amp;nbsp;&lt;strong&gt;&amp;lt;certificate-set-id&amp;gt;-certificate.pem.crt&amp;nbsp;&lt;/strong&gt;this&amp;nbsp;file as mentioned before has the&amp;nbsp;&amp;nbsp;&lt;em&gt;-----BEGIN CERTIFICATE-----&lt;/em&gt;&amp;nbsp;at the beginning of the file. The&amp;nbsp;&lt;strong&gt;private key&lt;/strong&gt; file should have a&amp;nbsp;&lt;em&gt;-----BEGIN RSA PRIVATE KEY-----&amp;nbsp;&lt;/em&gt;at the beginning, and the file format is usually &lt;strong&gt;&amp;lt;certificate-set-id&amp;gt;-private.pem.key&lt;/strong&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;It&amp;#39;s also important, as mentioned before that you follow the formatting of the certificates.h file&amp;nbsp;by having \n endings at the end of each new line in the certificates.h header file.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;I do recommend after &lt;strong&gt;provisioning&lt;/strong&gt; your &lt;strong&gt;certificates, &lt;/strong&gt;and you get a &lt;strong&gt;successful MQTT connection, &lt;/strong&gt;that you &lt;strong&gt;check&lt;/strong&gt;&amp;nbsp;the&amp;nbsp;&lt;strong&gt;&lt;span&gt;Use provisioned certificates&lt;/span&gt;&lt;/strong&gt; option again. This reduces the &lt;strong&gt;tear&lt;/strong&gt; on the modem &lt;strong&gt;flash&lt;/strong&gt;&amp;nbsp;by not &lt;strong&gt;writing&lt;/strong&gt; the certificates again to the &lt;strong&gt;modem. &lt;/strong&gt;Also, by having the option unchecked, your certificates &lt;b&gt;will be stored in the firmware &lt;/b&gt;image&amp;nbsp;and when flashed &lt;b&gt;in the flash of the device&lt;/b&gt;. By re-enabling the option, you avoid both these problems &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Connecting device to AWS IoT Core (aws_fota)</title><link>https://devzone.nordicsemi.com/thread/214540?ContentTypeID=1</link><pubDate>Fri, 11 Oct 2019 09:10:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09d79bdb-e85e-4c0a-a066-76b2604a2b11</guid><dc:creator>Hakon</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]CLOUD_CLIENT_PRIVATE_KEY is the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;private key,&lt;/strong&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;CLOUD_CLIENT_PUBLIC_CERTIFICATE is the&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;strong&gt;public key&lt;/strong&gt;&lt;span&gt;&lt;/span&gt;[/quote]
&lt;p&gt;&amp;nbsp;The private key should be &lt;span&gt;CLOUD_CLIENT_PRIVATE_KEY, that&amp;#39;s correct. As for the NRF_CLOUD_CLIENT_PUBLIC_CERTIFICATE, both of the remaining certificates (not CA) should be included here. It&amp;#39;s important that you separate them with a &lt;span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;-----BEGIN CERTIFICATE-----&lt;span&gt;\n&lt;/span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; and &lt;span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;-----END CERTIFICATE-----&lt;span&gt;\n&lt;/span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;. Also, I&amp;#39;m not sure what this does&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]I uncheck&amp;nbsp;&lt;strong&gt;&lt;span&gt;Use provisioned certificates&lt;/span&gt;&lt;/strong&gt;[/quote]
&lt;p&gt;&amp;nbsp;but you need to provision certificates, which can be done by adding the config option &lt;code&gt;CONFIG_NRF_CLOUD_PROVISION_CERTIFICATES&lt;/code&gt;=y.&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>