2024-08-17 11:49:55 +00:00
|
|
|
#include "unsecure_api.h"
|
|
|
|
#include "constants.h"
|
2024-08-18 14:56:05 +00:00
|
|
|
#include "http_client.h"
|
|
|
|
#include "esp_log.h"
|
2024-08-17 11:49:55 +00:00
|
|
|
|
2024-08-18 14:56:05 +00:00
|
|
|
static const char *TAG = "unsecure_api";
|
2024-08-17 11:49:55 +00:00
|
|
|
|
|
|
|
char *unsecure_api_get_secure_origin()
|
|
|
|
{
|
|
|
|
const char *url = BACKEND_UNSECURE_URL "/secure_origin";
|
2024-08-18 14:56:05 +00:00
|
|
|
|
|
|
|
http_request_opts opts = {.url = url};
|
|
|
|
char *res = http_client_exec(&opts);
|
|
|
|
|
|
|
|
if (!res)
|
|
|
|
{
|
|
|
|
ESP_LOGE(TAG, "Failed to query api secure origin!");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2024-08-18 17:42:40 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *unsecure_api_get_root_ca()
|
|
|
|
{
|
|
|
|
const char *url = BACKEND_UNSECURE_URL "/pki/root_ca.crt";
|
|
|
|
|
|
|
|
http_request_opts opts = {.url = url};
|
|
|
|
char *res = http_client_exec(&opts);
|
|
|
|
|
|
|
|
if (!res)
|
|
|
|
{
|
|
|
|
ESP_LOGE(TAG, "Failed to query root CA!");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2024-08-18 14:56:05 +00:00
|
|
|
return res;
|
2024-08-17 11:49:55 +00:00
|
|
|
}
|