Chat freely about anything...

User avatar
By Masoud Navidi
#88128 Hi everyone.

I have a code which does download updates available from a http site. I am asked to change the site address to a new one. this time, the site is https. how can I change my code to update my ESP with the file in this new address?

I'm sure you are all familiar with this code but I update it for you.

Code: Select allvoid update_esp()
{
  Serial.println("update_esp ==>");
  if ((WiFi.status() == WL_CONNECTED)) {

    Serial.println("Checking Update...");
    String file_add = esp_update_host +  esp_update_filename;
    Serial.printf("update address: ");
    Serial.println(file_add);
    t_httpUpdate_return ret = ESPhttpUpdate.update(file_add.c_str());

    switch (ret) {
      case HTTP_UPDATE_FAILED:
        Serial.printf("HTTP_UPDATE_FAILD Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
        Serial.println();
        break;

      case HTTP_UPDATE_NO_UPDATES:
        Serial.println("HTTP_UPDATE_NO_UPDATES");
        break;

      case HTTP_UPDATE_OK:
        Serial.println("HTTP_UPDATE_OK");
        break;
    }
  }

}
User avatar
By Bonzo
#88133 What you want to change is not in this piece of code but in the connect part; I believe you need to add the SSL certificate details.
All well and good but my server updates the certificate every year and if yours is the same you will need to change the code every year as well.
I have an https site but use a http add on for my downloads.
User avatar
By Masoud Navidi
#88148
Bonzo wrote:What you want to change is not in this piece of code but in the connect part; I believe you need to add the SSL certificate details.
All well and good but my server updates the certificate every year and if yours is the same you will need to change the code every year as well.
I have an https site but use a http add on for my downloads.


thanks for your answer. can you be more specific to what should I do? what should I write? where should I write?
do you have a sample code which actually works for you?
I have the certificate and the fingerprint. how should I use them?