This commit is contained in:
Sergio R. Caprile committed 2026-01-12 10:55:40 -03:00
1 parent db496fd7dd
commit e46ee68a95
4 files changed
+39 -39

No files matched your search

+1 -1
View File
@@ -34,7 +34,7 @@ void mg_tls_handshake(struct mg_connection *);
// Private
void mg_tls_ctx_init(struct mg_mgr *);
void mg_tls_ctx_free(struct mg_mgr *);
#define MG_IS_DER(buf) ((uint8_t) (buf)[0] == 0x30) // DER begins with 0x30
#define MG_IS_DER(buf) (((uint8_t *) (buf))[0] == 0x30) // DER begins with 0x30
// Low-level IO primives used by TLS layer
enum { MG_IO_ERR = -1, MG_IO_WAIT = -2, MG_IO_RESET = -3 };
+1 -1
View File
@@ -32,7 +32,7 @@ static int mg_mbed_rng(void *ctx, unsigned char *buf, size_t len) {
static bool mg_load_cert(struct mg_str str, mbedtls_x509_crt *p) {
int rc;
if (str.buf == NULL || str.buf[0] == '\0' || str.buf[0] == '*') return true;
if (!MG_IS_DER(str.buf[0])) str.len++; // PEM, include trailing NUL
if (!MG_IS_DER(str.buf)) str.len++; // PEM, include trailing NUL
if ((rc = mbedtls_x509_crt_parse(p, (uint8_t *) str.buf, str.len)) != 0) {
MG_ERROR(("cert err %#x", -rc));
return false;