OTA bin download using https

rename server root ca constant name
This commit is contained in:
samuelbles07
2024-11-30 04:33:58 +07:00
parent 401326d00d
commit aeee0cad01
3 changed files with 6 additions and 4 deletions

View File

@ -68,7 +68,7 @@ bool AgApiClient::fetchServerConfiguration(void) {
}
} else {
// By default, airgradient using https
if (client.begin(uri, AIRGRADIENT_SERVER_CA) == false) {
if (client.begin(uri, AG_SERVER_ROOT_CA) == false) {
logError("Begin HTTPClient using tls failed (GET)");
getConfigFailed = true;
return false;
@ -143,7 +143,7 @@ bool AgApiClient::postToServer(String data) {
}
} else {
// By default, airgradient using https
if (client.begin(uri, AIRGRADIENT_SERVER_CA) == false) {
if (client.begin(uri, AG_SERVER_ROOT_CA) == false) {
logError("Begin HTTPClient using tls failed (POST)");
getConfigFailed = true;
return false;

View File

@ -19,7 +19,8 @@
#endif
#ifndef ESP8266
const char *const AIRGRADIENT_SERVER_CA =
// Airgradient server root ca certificate
const char *const AG_SERVER_ROOT_CA =
"-----BEGIN CERTIFICATE-----\n"
"MIIF4jCCA8oCCQD7MgvcaVWxkTANBgkqhkiG9w0BAQsFADCBsjELMAkGA1UEBhMC\n"
"VEgxEzARBgNVBAgMCkNoaWFuZyBNYWkxEDAOBgNVBAcMB01hZSBSaW0xGTAXBgNV\n"

View File

@ -8,7 +8,7 @@ void OtaHandler::setHandlerCallback(OtaHandlerCallback_t callback) { _callback =
void OtaHandler::updateFirmwareIfOutdated(String deviceId) {
String url =
"http://hw.airgradient.com/sensors/airgradient:" + deviceId + "/generic/os/firmware.bin";
"https://hw.airgradient.com/sensors/airgradient:" + deviceId + "/generic/os/firmware.bin";
url += "?current_firmware=";
url += GIT_VERSION;
char urlAsChar[URL_BUF_SIZE];
@ -17,6 +17,7 @@ void OtaHandler::updateFirmwareIfOutdated(String deviceId) {
esp_http_client_config_t config = {};
config.url = urlAsChar;
config.cert_pem = AG_SERVER_ROOT_CA;
OtaUpdateOutcome ret = attemptToPerformOta(&config);
Serial.println(ret);
if (_callback) {