Simple SSL client with CyaSSL

Dependencies:   CyaSSL EthernetInterface mbed-rtos mbed

Fork of SimpleClient-TCP-FRDM by wolf SSL

Revision:
3:da3988eac4e0
Parent:
2:2e68626be425
--- a/main.cpp	Mon Dec 08 06:14:57 2014 +0000
+++ b/main.cpp	Mon Dec 08 13:08:09 2014 +0000
@@ -36,7 +36,7 @@
 
 EthernetInterface eth;
 
-main()
+void net_main(void const *av)
 {
     char server_ip[20] ;
 
@@ -52,7 +52,7 @@
     CYASSL*         ssl     = 0;
 
     CYASSL_METHOD* method = CyaTLSv1_2_client_method();
-
+    /* CyaSSL_Debugging_ON() ; */
     /* Initialize CyaSSL Context */
     ctx = CyaSSL_CTX_new(method);
     if (ctx == NULL)
@@ -88,7 +88,7 @@
     }
     printf("SSL Connected\n") ;
 
-    char msg[] = "GET / HTTP/1.0\r\nConnection: Close\r\n\r\n" ;
+    char msg[] = "GET /congrats.html HTTP/1.0\r\nConnection: Close\r\n\r\n" ;
     // const char msg[] = "Hello World\r\n" ;
 
     if (
@@ -105,8 +105,8 @@
         if (n >= 0) {
             buf[n] = 0;
             printf("%s", buf);
-        } else
-            err_sys("CyaSSL_read failed");
+        } else break ;
+
     } while(n > 0) ;
     puts("=== === === ===") ;
     CyaSSL_free(ssl) ; 
@@ -114,3 +114,15 @@
     CyaSSL_CTX_free(ctx) ; 
     eth.disconnect();
 }
+
+
+main()
+{
+
+#define STACK_SIZE 20000
+    Thread t(net_main, NULL, osPriorityNormal, STACK_SIZE);
+
+    while (true) {
+        Thread::wait(1000);
+    }
+}
\ No newline at end of file