Revert to the old TLS API, but keep certs as mg_str for DER

This commit is contained in:
cpq committed 2023-09-19 11:15:23 +01:00
1 parent 7ecbbc517d
commit 3f0366a514
31 files changed
+532 -782

No files matched your search

File renamed without changes.
+6 -2
View File
@@ -28,6 +28,12 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
// Connected to server. Extract host name from URL
struct mg_str host = mg_url_host(s_url);
if (mg_url_is_ssl(s_url)) {
struct mg_tls_opts opts = {.ca = mg_unpacked("/certs/ca.pem"),
.name = mg_url_host(s_url)};
mg_tls_init(c, &opts);
}
// Send request
int content_length = s_post_data ? strlen(s_post_data) : 0;
mg_printf(c,
@@ -59,8 +65,6 @@ int main(int argc, char *argv[]) {
if (argc > 1) s_url = argv[1]; // Use URL provided in the command line
mg_log_set(atoi(log_level)); // Set to 0 to disable debug
mg_mgr_init(&mgr); // Initialise event manager
struct mg_tls_opts opts = {.client_ca = mg_unpacked("/certs/client_ca.pem")};
mg_tls_ctx_init(&mgr, &opts);
mg_http_connect(&mgr, s_url, fn, &done); // Create client connection
while (!done) mg_mgr_poll(&mgr, 50); // Event manager loops until 'done'
mg_mgr_free(&mgr); // Free resources
+1 -1
View File
@@ -2556,7 +2556,7 @@ static const struct packed_file {
size_t size;
time_t mtime;
} packed_files[] = {
{"/certs/client_ca.pem", v1, sizeof(v1), 1694016785},
{"/certs/ca.pem", v1, sizeof(v1), 1694162397},
{NULL, NULL, 0, 0}
};