Iot | ESP8266 Estatablishing secure connection for Api Call

by Start Bootstrap

Posted on Jul 23, 2019

As i am done with the http call, i planned to take a step forward i.e., Establishing secure connection on Vemos ESP8266

Here's the process which took 2 hr for me, it will be simple for me in future.

Here's the full example code

#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecureBearSSL.h>
const uint8_t fingerprint[20] = {0x5A, 0xCF, 0xFE, 0xF0, 0xF1, 0xA6, 0xF4, 0x5F, 0xD2, 0x11, 0x11, 0xC6, 0x1D, 0x2F, 0x0E, 0xBC, 0x39, 0x8D, 0x50, 0xE0};
ESP8266WiFiMulti WiFiMulti;
void setup() {
  for (uint8_t t = 4; t > 0; t--) {
    Serial.printf("[SETUP] WAIT %d...\n", t);
  WiFiMulti.addAP("SSID", "PASSWORD");

void loop() {
  if (( == WL_CONNECTED)) {
    std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);
    HTTPClient https;
    Serial.print("[HTTPS] begin...\n");
    if (https.begin(*client, "")) {  // HTTPS
      Serial.print("[HTTPS] GET...\n");
      int httpCode = https.GET();
      if (httpCode > 0) {
        Serial.printf("[HTTPS] GET... code: %d\n", httpCode);
        if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
          String payload = https.getString();
      } else {
        Serial.printf("[HTTPS] GET... failed, error: %s\n", https.errorToString(httpCode).c_str());
    } else {
      Serial.printf("[HTTPS] Unable to connect\n");
  Serial.println("Wait 10s before next round...");

Step 1 : 

Get the fingerprint here : , it will look something like 

Step 2 : 

Just make it look like 


i.e., add 0X before the finger print

Replace your url and finger print in the url and just make your requests. 

It's done now 😉



Side Widget
You can put anything you want inside of these side widgets. They are easy to use, and feature the new Bootstrap 4 card containers!