Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: WNCInterface mbed-rtos mbed
Diff: main.cpp
- Revision:
- 9:1ac74f2d7bda
- Parent:
- 0:fc70c47eecb4
- Child:
- 12:419514568fef
- Child:
- 13: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;
}