diff --git a/include/handler_api.h b/include/handler_api.h index 774be063..2679470e 100644 --- a/include/handler_api.h +++ b/include/handler_api.h @@ -23,6 +23,7 @@ typedef struct void stats_update(const char *item, int count); error_t handleApiUploadCert(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx); +error_t handleApiGetCaDer(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx); error_t handleApiESP32UploadFirmware(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx); error_t handleApiESP32ExtractCerts(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx); error_t handleApiESP32PatchFirmware(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx); diff --git a/src/handler_api.c b/src/handler_api.c index d0e9f8fa..ffab5cd2 100644 --- a/src/handler_api.c +++ b/src/handler_api.c @@ -1144,6 +1144,16 @@ error_t file_save_end_suffix(void *in_ctx) return NO_ERROR; } +error_t handleApiGetCaDer(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx) +{ + settings_t *settings = get_settings(); + char *ca_path = custom_asprintf("%s%c%s", settings->internal.basedirfull, PATH_SEPARATOR, settings->core.server_cert.file.ca_der); + + error_t err = httpSendResponseUnsafe(connection, uri, ca_path); + osFreeMem(ca_path); + return err; +} + error_t handleApiESP32UploadFirmware(HttpConnection *connection, const char_t *uri, const char_t *queryString, client_ctx_t *client_ctx) { uint_t statusCode = 500; diff --git a/src/server.c b/src/server.c index 47979dc3..d121bb80 100644 --- a/src/server.c +++ b/src/server.c @@ -123,6 +123,8 @@ request_type_t request_paths[] = { {REQ_POST, "/api/dirDelete", SERTY_WEB, &handleApiDirectoryDelete}, {REQ_POST, "/api/dirCreate", SERTY_WEB, &handleApiDirectoryCreate}, {REQ_POST, "/api/uploadCert", SERTY_WEB, &handleApiUploadCert}, + {REQ_GET, "/api/getFile/ca.der", SERTY_WEB, &handleApiGetCaDer}, + {REQ_GET, "/api/getFile/c2.der", SERTY_WEB, &handleApiGetCaDer}, {REQ_POST, "/api/esp32/uploadFirmware", SERTY_WEB, &handleApiESP32UploadFirmware}, {REQ_POST, "/api/esp32/extractCerts", SERTY_WEB, &handleApiESP32ExtractCerts}, {REQ_GET, "/api/esp32/patchFirmware", SERTY_WEB, &handleApiESP32PatchFirmware},