Connect to a SSL Enabled REST API Server From ESP8266

I have developed Rest API Based Access Control System.

My Frontend is made with Arduino Nano and ESP8266. Backend Test System is Flask.

My ESP8266 part of the Code for Sending Rest POST Requests to Flask Backend API Server is Below,

if (sub3 == "31") { //New User Registartion
        String data =  "{\"user_id\" :\"" + sub1 + "\",\"encrypted_password\" :\"" + sub2 + "\",\"option\" :\"" + sub3 + "\" ,\"request_datetime\" :\"" + currentDate + "\"}";
        String link1 = "http://" + server + ":" + String(port) + "/users/";
        HTTPClient http; //Declare object of class HTTPClient
        http.begin(wifiClient, link1);     //Specify request destination
        http.addHeader("Content-Type", "application/json");
        int httpCode = http.POST(data.c_str());

        if (httpCode == 200) {
          String payload = http.getString();   //Get the response payload
          payload.trim(); // Remove line ending characters if any
          Serial.println(httpCode);   //Print HTTP return code
          Serial.println(payload);    //Print request response payload
          if (payload == "{\"Response\":\"Successful\"}") {
            link.read();
            Serial.println(F("Prompt other side Confirmation"));
            link.print("Successfuly_Registered");
            digitalWrite(statusLED, HIGH); //flash led to show data is arriving
            delay(20);
            digitalWrite(statusLED, LOW);
          }
          else if (httpCode != 200 )  {
            link.read();
            Serial.println(F("Prompt other side Error"));
            link.print("User_Exist");
            digitalWrite(statusLED, HIGH); //flash led to show data is arriving
            delay(20);
            digitalWrite(statusLED, LOW);

          }

        }
        http.end();
        rec = ""; // clear for next receive
        hexstring = ""; //Clear hexstring
      }

The method works perfectly in http, But now I have enabled https in Backend and wants to make the API call more secure.

Is there any way I can send the https REST POST Requests without changing much of the code since I am already in the end of completing the project ?

The code following the last quoted line will never be executed due to the first quoted line.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.