Skip to content

Commit beeb748

Browse files
committed
extmod/modussl_mbedtls: Allow to compile with MBEDTLS_DEBUG_C disabled.
With MBEDTLS_DEBUG_C disabled the function mbedtls_debug_set_threshold() doesn't exist. There's also no need to call mbedtls_ssl_conf_dbg() so a few bytes can be saved on disabling that and not needing the mbedtls_debug callback.
1 parent 68c2817 commit beeb748

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

extmod/modussl_mbedtls.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct ssl_args {
6767

6868
STATIC const mp_obj_type_t ussl_socket_type;
6969

70-
static void mbedtls_debug(void *ctx, int level, const char *file, int line, const char *str) {
70+
void mbedtls_debug(void *ctx, int level, const char *file, int line, const char *str) {
7171
printf("DBG:%s:%04d: %s\n", file, line, str);
7272
}
7373

@@ -123,8 +123,10 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) {
123123
mbedtls_x509_crt_init(&o->cert);
124124
mbedtls_pk_init(&o->pkey);
125125
mbedtls_ctr_drbg_init(&o->ctr_drbg);
126+
#ifdef MBEDTLS_DEBUG_C
126127
// Debug level (0-4)
127128
mbedtls_debug_set_threshold(0);
129+
#endif
128130

129131
mbedtls_entropy_init(&o->entropy);
130132
const byte seed[] = "upy";
@@ -144,7 +146,9 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) {
144146

145147
mbedtls_ssl_conf_authmode(&o->conf, MBEDTLS_SSL_VERIFY_NONE);
146148
mbedtls_ssl_conf_rng(&o->conf, mbedtls_ctr_drbg_random, &o->ctr_drbg);
149+
#ifdef MBEDTLS_DEBUG_C
147150
mbedtls_ssl_conf_dbg(&o->conf, mbedtls_debug, NULL);
151+
#endif
148152

149153
ret = mbedtls_ssl_setup(&o->ssl, &o->conf);
150154
if (ret != 0) {

0 commit comments

Comments
 (0)