I'm trying to perform an OTA update with esp-idf by downloading firmware from an S3 bucket. I'm using the following provided snippet:
esp_http_client_config_t config = {
.url = "https://my-bucket-name-here.s3.amazonaws.com/firmware.bin",
.cert_pem = (char *)server_cert_pem_start,
.event_handler = _http_event_handler,
};
esp_err_t ret = esp_https_ota(&config);
if (ret == ESP_OK) {
esp_restart();
} else {
ESP_LOGE(TAG, "Firmware upgrade failed");
}
When put that URL in my browser or wget it, the file downloads fine. However, the download fails on the ESP32. I get the following message:
␛[0;31mE (1043) esp-tls: couldn't get hostname for :my-bucket-name-here.s3.amazonaws.com:␛[0m
␛[0;31mE (1053) esp-tls: Failed to open new connection␛[0m>
␛[0;31mE (1063) TRANS_SSL: Failed to open a new connection␛[0m
␛[0;31mE (1063) HTTP_CLIENT: Connection failed, sock < 0␛[0m
␛[0;31mE (1073) esp_https_ota: Failed to open HTTP connection: ERROR␛[0m
␛[0;31mE (1073) esp_https_ota: Failed to establish HTTP connection␛[0m
␛[0;31mE (1083) subpub: Firmware upgrade failed␛[0m
I was able to track it down to the function that throws the first error. It's thrown by resolve_host_name()
in esp_tls.c
here. Specifically, the error occurs in this chunk of code:
if (getaddrinfo(use_host, NULL, &hints, address_info)) {
ESP_LOGE(TAG, "couldn't get hostname for :%s:", use_host);
free(use_host);
return ESP_ERR_ESP_TLS_CANNOT_RESOLVE_HOSTNAME;
}
Any clue why getaddrinfo
wouldn't be able to resolve an S3 bucket address? I thought I might have used the wrong certificate, but this seems to be before the certificate is even used.