Allow comments in PEM

This commit is contained in:
cpq authored and Sergio R. Caprile committed 2026-01-12 10:54:15 -03:00
1 parent 12491777bb
commit 0a3e129527
5 files changed
+14 -12

No files matched your search

+4 -4
View File
@@ -58,9 +58,9 @@ static EVP_PKEY *load_key(struct mg_str s) {
static X509 *load_cert(struct mg_str s) {
BIO *bio = BIO_new_mem_buf(s.buf, (int) (long) s.len);
X509 *cert = bio == NULL ? NULL
: s.buf[0] == '-'
? PEM_read_bio_X509(bio, NULL, NULL, NULL) // PEM
: d2i_X509_bio(bio, NULL); // DER
: MG_IS_DER(s.buf)
? d2i_X509_bio(bio, NULL) // DER
: PEM_read_bio_X509(bio, NULL, NULL, NULL); // PEM
if (bio) BIO_free(bio);
return cert;
}
@@ -259,7 +259,7 @@ size_t mg_tls_pending(struct mg_connection *c) {
long mg_tls_recv(struct mg_connection *c, void *buf, size_t len) {
struct mg_tls *tls = (struct mg_tls *) c->tls;
int n = SSL_read(tls->ssl, buf, (int) len);
if (!c->is_tls_hs && buf == NULL && n == 0) return 0; // TODO(): MIP
if (!c->is_tls_hs && buf == NULL && n == 0) return 0; // TODO(): MIP
if (n < 0 && mg_tls_err(c, tls, n) == 0) return MG_IO_WAIT;
if (n <= 0) return MG_IO_ERR;
return n;