mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-11 16:40:17 +00:00
close connection on bad CA or missing server cert for builtin TLS
This commit is contained in:
1 parent
c77e578a19
commit
65d15bb002
3 files changed
+17
-10
No files matched your search
+7
-3
@@ -2760,15 +2760,19 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
|
||||
mg_free(all_certs);
|
||||
} else { // parse again for a possible DER (or a truncated begin string)
|
||||
if (mg_parse_pem(opts->ca, mg_str_s("CERTIFICATE"), &tls->ca_der) < 0) {
|
||||
MG_ERROR(("Failed to load CA certificate"));
|
||||
goto xit;
|
||||
mg_error(c, "Failed to load CA certificate");
|
||||
return;
|
||||
}
|
||||
} // ca_bundle_len != 0 && ca_der.len = 0 => bundle
|
||||
if (!c->is_client) tls->is_twoway = true; // server + CA: two-way auth
|
||||
}
|
||||
|
||||
if (opts->cert.buf == NULL || opts->cert.len == 0) {
|
||||
MG_VERBOSE(("No certificate provided"));
|
||||
if (!c->is_client) {
|
||||
mg_error(c, "No server certificate provided");
|
||||
return;
|
||||
}
|
||||
MG_VERBOSE(("No client certificate provided"));
|
||||
goto xit;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user