Connect a secure socket with TLS server authentication through X-NUCLEO_IDW01M1 Wi-Fi.
Dependencies: NetworkSocketAPI X_NUCLEO_IDW01M1v2 mbed
Fork of HelloWorld_IDW01M1v2 by
Example of TLS connection using X-NUCLEO-IDW01M1 Wi-Fi expansion board.
The application is meant to be used with mbed OS 2 ("Classic") only (no mbedOS 5 support).
It uses the TLS/SSL feature provided natively by the Wi-Fi module and performs secure connection to https://mbed.org also verifying the server identity.
To avoid expired CA certificates, system time (in epoch) must be manually entered (e..g. using http://www.epochconverter.com/ ) .
Retrieval of current time from an NTP server is shown by this example.
Diff: main.cpp
- Revision:
- 9:13bd9c989e6c
- Parent:
- 8:74b827befe72
- Child:
- 10:cc61a766cd1f
diff -r 74b827befe72 -r 13bd9c989e6c main.cpp
--- a/main.cpp Thu Jan 05 09:39:03 2017 +0000
+++ b/main.cpp Tue Jan 10 09:20:31 2017 +0000
@@ -144,8 +144,10 @@
int t=0;
scanf("%d",&t);
printf ("entered time is: %d \n\r", t);
- if (t != 0) { time_t txTm = t; set_time(txTm); }
- printf ("The current system time is: %s", ctime (&ctTime));
+ if (t != 0) { time_t txTm = t; set_time(txTm); } // set Nucleo system time
+ ctTime = time(NULL);
+ printf ("The current system time is: %s", ctime (&ctTime)); // set WiFi module systm time
+ if (!spwf.set_time(ctTime)) printf ("ERROR set_time\n\r");
if (!spwf.clean_TLS_certificate(ALL)) printf ("ERROR clean_TLS_certificate\n\r");
if (!spwf.set_TLS_certificate(CA_cert, sizeof(CA_cert), FLASH_CA_ROOT_CERT)) printf ("ERROR set_TLS_certificate\n\r");
if (!spwf.set_TLS_SRV_domain("www.amazon.it",FLASH_DOMAIN)) printf ("ERROR set_TLS_CA_domain\n\r");
