diff options
| author | Damien George | 2017-09-06 17:34:45 +1000 |
|---|---|---|
| committer | Damien George | 2017-09-06 17:34:45 +1000 |
| commit | beeb7483d889f5880895ecdd8e7a354f16956037 (patch) | |
| tree | 03fce21ebf3cc6daf62fe3532259984e2580d0be /extmod | |
| parent | 68c28174d0e0ec3f6b1461aea3a0b6a1b84610bb (diff) | |
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.
Diffstat (limited to 'extmod')
| -rw-r--r-- | extmod/modussl_mbedtls.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/extmod/modussl_mbedtls.c b/extmod/modussl_mbedtls.c index 12ec60a75..a65470e16 100644 --- a/extmod/modussl_mbedtls.c +++ b/extmod/modussl_mbedtls.c @@ -67,7 +67,7 @@ struct ssl_args { STATIC const mp_obj_type_t ussl_socket_type; -static void mbedtls_debug(void *ctx, int level, const char *file, int line, const char *str) { +void mbedtls_debug(void *ctx, int level, const char *file, int line, const char *str) { printf("DBG:%s:%04d: %s\n", file, line, str); } @@ -123,8 +123,10 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) { mbedtls_x509_crt_init(&o->cert); mbedtls_pk_init(&o->pkey); mbedtls_ctr_drbg_init(&o->ctr_drbg); + #ifdef MBEDTLS_DEBUG_C // Debug level (0-4) mbedtls_debug_set_threshold(0); + #endif mbedtls_entropy_init(&o->entropy); const byte seed[] = "upy"; @@ -144,7 +146,9 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) { mbedtls_ssl_conf_authmode(&o->conf, MBEDTLS_SSL_VERIFY_NONE); mbedtls_ssl_conf_rng(&o->conf, mbedtls_ctr_drbg_random, &o->ctr_drbg); + #ifdef MBEDTLS_DEBUG_C mbedtls_ssl_conf_dbg(&o->conf, mbedtls_debug, NULL); + #endif ret = mbedtls_ssl_setup(&o->ssl, &o->conf); if (ret != 0) { |
