'Connecting an ESP8266 to AWS IoT Core - getting "WiFiClientSecure SSL error: Unknown error code."

I am trying my first ever IoT project with an ESP8266 connecting to AWS IoT core. I've checked all my certificates, setup etc and they appear to be correct. However, when I run my code to publish a simple "Hello World" message to AWS IoT, I get:

Attempting MQTT connection...pm open,type:2 0 failed, rc=-4 try again in 5 seconds WiFiClientSecure SSL error: Unknown error code.

Any help would be greatly appreciated. If you need any more detail, I'd be happy to provide it.

Thanx,

ramesh.



Solution 1:[1]

I ran into a similar issue and what I ended up finding is that you have to set your certificates BEFORE you connect to the WiFi.

So try and make sure that you are setting those before calling WiFi.begin(ssid, password)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 justindra