-->
Page 1 of 2

OTA update from https

PostPosted: Thu Jul 30, 2020 4:44 am
by Masoud Navidi
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;
    }
  }

}

Re: OTA update from https

PostPosted: Thu Jul 30, 2020 12:50 pm
by Bonzo
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.

Re: OTA update from https

PostPosted: Sat Aug 01, 2020 12:44 am
by Masoud Navidi
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?

Re: OTA update from https

PostPosted: Sat Aug 01, 2020 3:54 am
by Bonzo
AS I say I do not use https but this is what you want to try ( copied from https://forum.arduino.cc/index.php?topic=515541.0 ):

Code: Select allhttp.begin("https://mysite.com/climate/status.php?id=1","55 25 65 47 85 7C 63 CD HH 08 62 57 B5 13 65 FF FF C0 FF 9E FG");