![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
V.06 11/3
Dependencies: FT6206 SDFileSystem SPI_TFT_ILI9341 TFT_fonts
Fork of ATT_AWS_IoT_demo by
Diff: main.cpp
- Revision:
- 9:1ac74f2d7bda
- Parent:
- 0:fc70c47eecb4
- Child:
- 12:1ae41c231014
diff -r 50d4701593ad -r 1ac74f2d7bda main.cpp --- a/main.cpp Sat Aug 20 00:00:22 2016 +0100 +++ b/main.cpp Tue Sep 06 16:30:30 2016 +0100 @@ -267,8 +267,9 @@ /* It also means the handshake is done, time to print info */ printf("TLS connection to %s established\r\n", HTTPS_SERVER_NAME); - char buf[1024]; - mbedtls_x509_crt_info(buf, sizeof(buf), "\r ", + const uint32_t buf_size = 1024; + char *buf = new char[buf_size]; + mbedtls_x509_crt_info(buf, buf_size, "\r ", mbedtls_ssl_get_peer_cert(&_ssl)); mbedtls_printf("Server certificate:\r\n%s\r", buf); @@ -276,7 +277,7 @@ uint32_t flags = mbedtls_ssl_get_verify_result(&_ssl); if( flags != 0 ) { - mbedtls_x509_crt_verify_info(buf, sizeof (buf), "\r ! ", flags); + mbedtls_x509_crt_verify_info(buf, buf_size, "\r ! ", flags); printf("Certificate verification failed:\r\n%s\r\r\n", buf); } else @@ -291,6 +292,7 @@ print_mbedtls_error("mbedtls_ssl_read", ret); onError(_tcpsocket, -1 ); } + delete[] buf; return; } _bpos = static_cast<size_t>(ret); @@ -310,6 +312,7 @@ _error = !(_got200 && _gothello); _tcpsocket->close(); + delete[] buf; } /** * Check if the test has completed. @@ -370,21 +373,23 @@ */ static int my_verify(void *data, mbedtls_x509_crt *crt, int depth, uint32_t *flags) { - char buf[1024]; + const uint32_t buf_size = 1024; + char *buf = new char[buf_size]; (void) data; mbedtls_printf("\nVerifying certificate at depth %d:\n", depth); - mbedtls_x509_crt_info(buf, sizeof (buf) - 1, " ", crt); + mbedtls_x509_crt_info(buf, buf_size - 1, " ", crt); mbedtls_printf("%s", buf); if (*flags == 0) mbedtls_printf("No verification issue for this certificate\n"); else { - mbedtls_x509_crt_verify_info(buf, sizeof (buf), " ! ", *flags); + mbedtls_x509_crt_verify_info(buf, buf_size, " ! ", *flags); mbedtls_printf("%s\n", buf); } + delete[] buf; return 0; } #endif @@ -467,6 +472,7 @@ mbedtls_printf("No Client IP Address\r\n"); } - HelloHTTPS hello(HTTPS_SERVER_NAME, HTTPS_SERVER_PORT, ð_iface); - hello.startTest(HTTPS_PATH); + HelloHTTPS *hello = new HelloHTTPS(HTTPS_SERVER_NAME, HTTPS_SERVER_PORT, ð_iface); + hello->startTest(HTTPS_PATH); + delete hello; }