diff --git a/mongoose.c b/mongoose.c index 6713de97..ddea6915 100644 --- a/mongoose.c +++ b/mongoose.c @@ -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; } diff --git a/src/tls_builtin.c b/src/tls_builtin.c index 1a2c15cc..6a7fb3c8 100644 --- a/src/tls_builtin.c +++ b/src/tls_builtin.c @@ -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; }