set is_tls at mg_listen and mg_connect level

This commit is contained in:
Sergio R. Caprile committed 2025-05-26 09:42:48 -03:00
1 parent 29594283c1
commit b740c80855
25 files changed
+69 -49

No files matched your search

+1 -1
View File
@@ -40,7 +40,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
if (ev == MG_EV_OPEN) {
// c->is_hexdumping = 1;
} else if (ev == MG_EV_CONNECT) {
if (mg_url_is_ssl(s_url)) {
if (c->is_tls) {
struct mg_tls_opts opts = {.ca = mg_unpacked("/ca.pem"),
.cert = mg_unpacked("/crt.pem"),
.key = mg_unpacked("/key.pem"),
@@ -59,7 +59,7 @@ void handle_command(struct mg_str msg) {
}
static void mqtt_ev_handler(struct mg_connection *c, int ev, void *ev_data) {
if (ev == MG_EV_CONNECT && mg_url_is_ssl(MQTT_SERVER)) {
if (c->is_tls && ev == MG_EV_CONNECT) {
struct mg_tls_opts opts = {};
opts.ca = mg_str(TLS_CA);
mg_tls_init(c, &opts);
+1 -1
View File
@@ -29,7 +29,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
MG_INFO(("%lu CREATED", c->id));
// c->is_hexdumping = 1;
} else if (ev == MG_EV_CONNECT) {
if (mg_url_is_ssl(s_url)) {
if (c->is_tls) {
struct mg_tls_opts opts = {.ca = mg_unpacked("/certs/ca.pem"),
.name = mg_url_host(s_url)};
mg_tls_init(c, &opts);
+1 -1
View File
@@ -25,7 +25,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
// On error, log error message
MG_ERROR(("%p %s", c->fd, (char *) ev_data));
} else if (ev == MG_EV_CONNECT) {
if (mg_url_is_ssl(s_url)) {
if (c->is_tls) {
struct mg_tls_opts opts = {.ca = mg_unpacked("/certs/ca.pem"),
.name = mg_url_host(s_url)};
mg_tls_init(c, &opts);