mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-12 16:50:21 +00:00
Fix built-in TLS CA bundle, cleanup
This commit is contained in:
1 parent
548c3dc77f
commit
73ed158e76
4 files changed
+92
-42
No files matched your search
+10
-2
@@ -179,14 +179,22 @@ static void fcb(struct mg_connection *c, int ev, void *ev_data) {
|
||||
if (mg_url_is_ssl(fd->url)) {
|
||||
struct mg_tls_opts opts;
|
||||
memset(&opts, 0, sizeof(opts)); // read CA from packed_fs
|
||||
opts.name = mg_url_host(fd->url);
|
||||
opts.ca = mg_unpacked("/data/ca.pem");
|
||||
if (host_ip != NULL && strstr(fd->url, host_ip) != NULL) {
|
||||
MG_DEBUG(("Local connection, using self-signed certificates"));
|
||||
opts.name = mg_str_s("localhost");
|
||||
opts.ca = mg_unpacked("/certs/ca.crt");
|
||||
} else {
|
||||
opts.name = mg_url_host(fd->url);
|
||||
opts.ca = mg_unpacked("/data/ca.pem");
|
||||
#if MG_TLS == MG_TLS_BUILTIN
|
||||
// our TLS does not search for the proper CA in a bundle
|
||||
opts.ca = mg_file_read(&mg_fs_posix, "data/e5.crt");
|
||||
#endif
|
||||
}
|
||||
mg_tls_init(c, &opts);
|
||||
#if MG_TLS == MG_TLS_BUILTIN
|
||||
mg_free((void *) opts.ca.buf);
|
||||
#endif
|
||||
}
|
||||
} else if (ev == MG_EV_HTTP_MSG) {
|
||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||
|
||||
Reference in new issue
Block a user