can't setup SSL connection even though it appears to connect with NodeMCU ESP8266 to AWS

纵然是瞬间 提交于 2020-02-06 07:55:09

问题


I'm trying to connect a NodeMCU ESP8266 and upload a shadow. I am following the tutorial from IoT Design Pro. When i first ran it, I did see the shadow updated on AWS. On subsequent loops, it stopped updating. Now i get a message "can't setup SSL connection". Here are my code and the serial output window:

#include <ESP8266WiFi.h>

#include <AmazonIOTClient.h>

#include "ESP8266AWSImplementations.h"

Esp8266HttpClient httpClient;

Esp8266DateTimeProvider dateTimeProvider;

AmazonIOTClient iotClient;

ActionError actionError;

char *ssid="xxxxxxxxxxxxxxxxxxx";

char *password="xxxxxxxxxxx";

void setup() {

  Serial.begin(115200);

  delay(10);

  // Connect to WAP

  Serial.print("Connecting to ");

  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {

    delay(500);

    Serial.print(".");

  }

  Serial.println("");

  Serial.println("WiFi connected");

  Serial.println("IP address: ");

  Serial.println(WiFi.localIP());



  iotClient.setAWSRegion("us-west-2");//axxxxxxxxxxxb-ats.iot.us-west-2.amazonaws.com

  iotClient.setAWSEndpoint("amazonaws.com");

  iotClient.setAWSDomain("axxxxxxxxxxxb-ats.iot.us-west-2.amazonaws.com");

  iotClient.setAWSPath("/things/MyThing/shadow");

  iotClient.setAWSKeyID("AxxxxxxxxxxxxxxxxxxW");

  iotClient.setAWSSecretKey("BxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxWmN1");

  iotClient.setHttpClient(&httpClient);

  iotClient.setDateTimeProvider(&dateTimeProvider);

}



void loop(){

  char* shadow = "{\"state\":{\"reported\": {\"Foobar\": \"bar\"}}}";

  char* result = iotClient.update_shadow(shadow, actionError);

  Serial.print(result);

  delay(500000);

}

with serial output:

WiFi connected
IP address: 
10.1.10.128
a2rl12mynda91b-ats.iot.us-west-2.amazonaws.com
443
POST /things/MyThing/shadow HTTP/1.1
Content-Type: application/json
Connection: close
Content-Length: 41
Host: axxxxxxxxxxxb-ats.iot.us-west-2.amazonaws.com
x-amz-content-sha256: d8af3f7d20512e6c2f9feddf0e729a9f9201023da39cde8ffa6826175c069174
x-amz-date: 20200122T221521Z
Authorization: AWS4-HMAC-SHA256 Credential=AxxxxxxxxxxxxxxxxxxW/20200122/us-west-2/iotdata/aws4_request,SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date,Signature=1d5e8b7d70a67d91704403796fd7bdae28b7f9396523314af98e3e1857b4368a

{"state":{"reported": {"Foobar": "bar"}}}




can't setup SSL connection

And AWS IoT shadow output: Does the serial output indicate it connected or not? I would think with the Authorization line it would be implying it is connecting, no? I can't see where I am going wrong.

Thanks.


回答1:


A similar problem happened to me.

Having 2 boards ESP32 and ESP8266 only 32 were able to make the request over HTTPS.

Option 1: Send requests without SSL

Option 2: Send requests with the correct fingerprint

Some helpful links:

https://buger.dread.cz/simple-esp8266-https-client-without-verification-of-certificate-fingerprint.html

https://github.com/esp8266/Arduino/issues/3417



来源:https://stackoverflow.com/questions/59869229/cant-setup-ssl-connection-even-though-it-appears-to-connect-with-nodemcu-esp826

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!