Fixed cert emptiness check

This commit is contained in:
cpq committed 2026-10-06 12:33:02 +01:00
1 parent be40827e17
commit 393c811f31
2 files changed
+4 -4

No files matched your search

+2 -2
View File
@@ -19602,7 +19602,7 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
if (!c->is_client) tls->is_twoway = true; // server + CA: two-way auth
}
if (opts->cert.buf == NULL) {
if (opts->cert.buf == NULL || opts->cert.len == 0) {
MG_VERBOSE(("No certificate provided"));
goto xit;
}
@@ -19631,7 +19631,7 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
}
// parse PEM or DER EC key
if (opts->key.buf == NULL) {
if (opts->key.buf == NULL || opts->key.len == 0) {
mg_error(c, "Certificate provided without a private key");
return;
}
+2 -2
View File
@@ -2733,7 +2733,7 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
if (!c->is_client) tls->is_twoway = true; // server + CA: two-way auth
}
if (opts->cert.buf == NULL) {
if (opts->cert.buf == NULL || opts->cert.len == 0) {
MG_VERBOSE(("No certificate provided"));
goto xit;
}
@@ -2762,7 +2762,7 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
}
// parse PEM or DER EC key
if (opts->key.buf == NULL) {
if (opts->key.buf == NULL || opts->key.len == 0) {
mg_error(c, "Certificate provided without a private key");
return;
}