Skip to content

Commit

Permalink
add /api/getFile/ca.der + /api/getFile/c2.der API
Browse files Browse the repository at this point in the history
  • Loading branch information
SciLor committed Nov 11, 2024
1 parent 6229c0f commit 8fc3de6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/handler_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions src/handler_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit 8fc3de6

Please sign in to comment.