Skip to content

Commit f98cae7

Browse files
committed
Don't try to load certificate and private key if it is null
1 parent 1551076 commit f98cae7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ssl/loader.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,9 @@ int load_key_certs(SSL_CTX *ssl_ctx)
436436
#if defined(CONFIG_SSL_USE_DEFAULT_KEY) || defined(CONFIG_SSL_SKELETON_MODE)
437437
extern const unsigned char* default_private_key;
438438
extern const unsigned int default_private_key_len;
439-
440-
ssl_obj_memory_load(ssl_ctx, SSL_OBJ_RSA_KEY, default_private_key,
441-
default_private_key_len, NULL);
439+
if (default_private_key != NULL && default_private_key_len > 0)
440+
ssl_obj_memory_load(ssl_ctx, SSL_OBJ_RSA_KEY, default_private_key,
441+
default_private_key_len, NULL);
442442
#endif
443443
}
444444

@@ -464,7 +464,8 @@ int load_key_certs(SSL_CTX *ssl_ctx)
464464
#if defined(CONFIG_SSL_USE_DEFAULT_KEY) || defined(CONFIG_SSL_SKELETON_MODE)
465465
extern const unsigned char* default_certificate;
466466
extern const unsigned int default_certificate_len;
467-
ssl_obj_memory_load(ssl_ctx, SSL_OBJ_X509_CERT,
467+
if (default_certificate != NULL && default_certificate_len > 0)
468+
ssl_obj_memory_load(ssl_ctx, SSL_OBJ_X509_CERT,
468469
default_certificate, default_certificate_len, NULL);
469470
#endif
470471
}

0 commit comments

Comments
 (0)