Fix debug mode in example-tls-client

Fixes #242
This commit is contained in:
Manuel Pégourié-Gonnard 2015-08-18 20:52:18 +02:00
parent 1a18aaecde
commit e50f67c18a

View File

@ -256,19 +256,27 @@ protected:
* Debug callback for mbed TLS * Debug callback for mbed TLS
* Just prints on the USB serial port * Just prints on the USB serial port
*/ */
static void my_debug(void *ctx, int level, const char *str) static void my_debug(void *ctx, int level, const char *file, int line,
const char *str)
{ {
const char *p, *basename;
(void) ctx; (void) ctx;
(void) level;
printf("%s", str); /* Extract basename from file */
for(p = basename = file; *p != '\0'; p++) {
if(*p == '/' || *p == '\\') {
basename = p + 1;
}
}
printf("%s:%04d: |%d| %s", basename, line, level, str);
} }
/** /**
* Certificate verification callback for mbed TLS * Certificate verification callback for mbed TLS
* Here we only use it to display information on each cert in the chain * Here we only use it to display information on each cert in the chain
*/ */
static int my_verify(void *data, mbedtls_x509_crt *crt, int depth, int *flags) static int my_verify(void *data, mbedtls_x509_crt *crt, int depth, uint32_t *flags)
{ {
char buf[1024]; char buf[1024];
(void) data; (void) data;