Help with HTTPs on Wifimanager NodeMCU

Hello, my code is working fine if I disable the HTTPS on my website, I can send info to the page and receive it back on the NodeMCU, but when I activate the HTTPS and change the link on my code to HTTPS it just doesn't work and does nothing on the website.

Can someone help me to make my code work with HTTPS? I really have no clue why it is not working.

My code is the following:

#include <ESP8266WiFi.h>     
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
//RFID Library
#include <SPI.h>
#include <MFRC522.h>        

//WiFiManager
#include <DNSServer.h>            
#include <WiFiManager.h>          

//************************************************************************
#define SS_PIN D8 
#define RST_PIN D3
#define GreenLed D1
#define RedLed D2
#define YellowLed D0
//************************************************************************

#include <Ticker.h>
Ticker ticker;

void tick()
{  
  int state = digitalRead(RedLed);  
  digitalWrite(RedLed, !state);     
}

//************************************************************************

void configModeCallback (WiFiManager *myWiFiManager) {
  Serial.println("Entered config mode");
  Serial.println(WiFi.softAPIP());
  Serial.println(myWiFiManager->getConfigPortalSSID());
  ticker.attach(0.2, tick);
}
//************************************************************************
MFRC522 mfrc522(SS_PIN, RST_PIN); 
//************************************************************************

const char* device_token  = "753a00399b5e86e8";
//************************************************************************
String URL = "http://website.com/data.php"; 
String getData, Link;
String OldCardID = "";
unsigned long previousMillis = 0;
//************************************************************************
void setup() {
  delay(1000);
  Serial.begin(115200);
  pinMode(RedLed, OUTPUT);
  ticker.attach(0.6, tick);
  
  WiFiManager wifiManager;
  wifiManager.setAPCallback(configModeCallback);
 
  if (!wifiManager.autoConnect("AP", "APPASSWORD")) {
    Serial.println("failed to connect and hit timeout");
    
    ESP.reset();
    delay(1000);
  }

  
  Serial.println("WiFi Conn OK! :D");
  ticker.detach();

  digitalWrite(RedLed, LOW);

  SPI.begin();  
  mfrc522.PCD_Init(); 

  pinMode(GreenLed, OUTPUT);
  pinMode(RedLed, OUTPUT);
  pinMode(YellowLed, OUTPUT);
}
//************************************************************************
void loop() {

  if ((WiFi.status() != WL_CONNECTED) || (WiFi.localIP().toString() == "0.0.0.0")) {
    ticker.attach(0.2, tick);
    Serial.println("ROUTER DISCONNECTED !!!!");

    WiFiManager wifiManager;
    wifiManager.setConnectTimeout(180); 
    wifiManager.setConfigPortalTimeout(120); 
    wifiManager.autoConnect("AP", "APPASSWORD");
    Serial.println("Connected to Wifi");
    ticker.detach();
  }

  else {


    //---------------------------------------------
    if (millis() - previousMillis >= 15000) {
      previousMillis = millis();
      OldCardID = "";
    }
    delay(50);
    //---------------------------------------------
    //look for new card
    if ( ! mfrc522.PICC_IsNewCardPresent()) {
    }
    if ( ! mfrc522.PICC_ReadCardSerial()) {
    }
    String CardID = "";
    for (byte i = 0; i < mfrc522.uid.size; i++) {
      CardID += mfrc522.uid.uidByte[i];
    }
    //---------------------------------------------
    if ( CardID == OldCardID ) {
      digitalWrite(YellowLed, HIGH);
      delay(300);
      digitalWrite(YellowLed, LOW);
      return;
    }
    else {
      OldCardID = CardID;
    }
    //---------------------------------------------
    //  Serial.println(CardID);
    SendCardID(CardID);
    delay(1000);
  }
}
void SendCardID( String Card_uid ) {
  Serial.println("Sending the Card ID");

  WiFiClient client; 
  HTTPClient http;  
  getData = "?card_uid=" + String(Card_uid) + "&device_token=" + String(device_token); 
  Link = URL + getData;
  http.begin(client, Link);

  int httpCode = http.GET();  
  String payload = http.getString();   


  if (httpCode == 200) {
    if (payload.substring(0, 5) == "login") {
      String user_name = payload.substring(5);
      //  Serial.println(user_name);
      digitalWrite(GreenLed, HIGH);
      Serial.println("Green on");
      delay(500); 
    }
    else if (payload == "available") {
      digitalWrite(RedLed, HIGH);
      digitalWrite(GreenLed, HIGH);
      digitalWrite(YellowLed, HIGH);
      delay(500);
    }
    delay(500);
    http.end();  
    digitalWrite(GreenLed, LOW);
    digitalWrite(RedLed, LOW);
    digitalWrite(YellowLed, LOW);
  }
}

Install library WiFiClientSecure and Try to replace

#include <WiFiClient.h>

by

#include <WiFiClientSecure.h> 

check also the examples that come with WiFiClientSecure.

Hello, and thanks for your answer, I did tested yesterday replacing the wificlient by wificlientsecure but still had the same problem, I will give it another try today when I arrive home.

If you have access to the http server terminal, try to get tcpdump trace while sending the https request from the ESP8266. You can attach the trace to this post.

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