mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-17 19:30:36 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f157bd23b |
No files matched your search
+2
-2
@@ -21153,8 +21153,8 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
|
|||||||
mg_error(c, "hostname too long");
|
mg_error(c, "hostname too long");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
strncpy((char *) tls->hostname, opts->name.buf, sizeof(tls->hostname) - 1);
|
memcpy(tls->hostname, opts->name.buf, opts->name.len);
|
||||||
tls->hostname[opts->name.len] = 0;
|
tls->hostname[opts->name.len] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
// server CA certificate; parse PEM [bundle] or DER
|
// server CA certificate; parse PEM [bundle] or DER
|
||||||
|
|||||||
+8
-8
@@ -2748,8 +2748,8 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
|
|||||||
mg_error(c, "hostname too long");
|
mg_error(c, "hostname too long");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
strncpy((char *) tls->hostname, opts->name.buf, sizeof(tls->hostname) - 1);
|
memcpy(tls->hostname, opts->name.buf, opts->name.len);
|
||||||
tls->hostname[opts->name.len] = 0;
|
tls->hostname[opts->name.len] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
// server CA certificate; parse PEM [bundle] or DER
|
// server CA certificate; parse PEM [bundle] or DER
|
||||||
@@ -2762,16 +2762,15 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
|
|||||||
tls->ca_bundle_der = all_certs;
|
tls->ca_bundle_der = all_certs;
|
||||||
MG_VERBOSE(("%d-cert bundle", cert_count));
|
MG_VERBOSE(("%d-cert bundle", cert_count));
|
||||||
} else if (cert_count > 0) {
|
} else if (cert_count > 0) {
|
||||||
int i;
|
tls->ca_der.buf = all_certs[0].buf;
|
||||||
tls->ca_der = all_certs[0];
|
tls->ca_der.len = all_certs[0].len;
|
||||||
for (i = 1; i < cert_count; i++) mg_free((void *) all_certs[i].buf);
|
|
||||||
mg_free(all_certs);
|
mg_free(all_certs);
|
||||||
} else { // parse again for a possible DER (or a truncated begin string)
|
} 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) {
|
if (mg_parse_pem(opts->ca, mg_str_s("CERTIFICATE"), &tls->ca_der) < 0) {
|
||||||
mg_error(c, "Failed to load CA certificate");
|
mg_error(c, "Failed to load CA certificate");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} // ca_bundle_len != 0 && ca_der.len = 0 => bundle
|
} // ca_bundle_len != 0 && ca_der.len = 0 => bundle
|
||||||
if (!c->is_client) tls->is_twoway = true; // server + CA: two-way auth
|
if (!c->is_client) tls->is_twoway = true; // server + CA: two-way auth
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2790,7 +2789,8 @@ void mg_tls_init(struct mg_connection *c, const struct mg_tls_opts *opts) {
|
|||||||
int cert_count = mg_parse_pem_certs(opts->cert, &all_certs);
|
int cert_count = mg_parse_pem_certs(opts->cert, &all_certs);
|
||||||
|
|
||||||
if (cert_count > 0) {
|
if (cert_count > 0) {
|
||||||
tls->cert_der = all_certs[0];
|
tls->cert_der.buf = all_certs[0].buf;
|
||||||
|
tls->cert_der.len = all_certs[0].len;
|
||||||
if (cert_count > 1) {
|
if (cert_count > 1) {
|
||||||
tls->chain_len = (size_t) cert_count;
|
tls->chain_len = (size_t) cert_count;
|
||||||
tls->chain_der = all_certs;
|
tls->chain_der = all_certs;
|
||||||
|
|||||||
Reference in new issue
Block a user