This is the new MiniTLS Program which build the connection with the website httpbin.org. The time of the program will last only for one year

Dependencies:   EthernetInterface newMiniTLS-GPL NewMiniTLS-HTTPSClient__Jacobshi mbed-rtos mbed

Fork of MiniTLS-HTTPS-Example by Donatien Garnier

Committer:
MiniTLS
Date:
Tue Jun 10 14:24:20 2014 +0000
Revision:
0:60de3ce23ca9
Child:
1:4a6e2b2faca6
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MiniTLS 0:60de3ce23ca9 1 #include "mbed.h"
MiniTLS 0:60de3ce23ca9 2 #include "EthernetInterface.h"
MiniTLS 0:60de3ce23ca9 3 #include "HTTPClient.h"
MiniTLS 0:60de3ce23ca9 4 #include "MiniTLS-GPL/cpp/MiniTLS.h"
MiniTLS 0:60de3ce23ca9 5
MiniTLS 0:60de3ce23ca9 6 MiniTLS miniTLS;
MiniTLS 0:60de3ce23ca9 7 EthernetInterface eth;
MiniTLS 0:60de3ce23ca9 8 HTTPClient http;
MiniTLS 0:60de3ce23ca9 9 char str[512];
MiniTLS 0:60de3ce23ca9 10
MiniTLS 0:60de3ce23ca9 11 const uint8_t pub_key[] = {
MiniTLS 0:60de3ce23ca9 12 /*0x30,0x82,0x01,0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,
MiniTLS 0:60de3ce23ca9 13 0x01,0x05,0x00,0x03,0x82,0x01,0x0F,0x00,*/0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,
MiniTLS 0:60de3ce23ca9 14 0x00,0xEC,0x4F,0x55,0x0A,0xD8,0xB1,0x6D,0xA1,0xB1,0x9F,0x1C,0xD8,0x93,0xE9,0x64,
MiniTLS 0:60de3ce23ca9 15 0x64,0x77,0x14,0x28,0x53,0x70,0xD6,0x4F,0xCF,0x99,0x3A,0x38,0x36,0xF9,0x7B,0x77,
MiniTLS 0:60de3ce23ca9 16 0xAB,0x0C,0x1D,0xE0,0x5B,0x55,0x93,0x09,0x34,0x31,0x8A,0x98,0xF0,0x98,0xB8,0x29,
MiniTLS 0:60de3ce23ca9 17 0xC2,0xF8,0x1E,0xFF,0xD8,0x8F,0xD5,0x91,0x4C,0xD6,0x32,0xF2,0x67,0x33,0x79,0xF4,
MiniTLS 0:60de3ce23ca9 18 0x4E,0x92,0xD8,0x75,0xD3,0x2F,0xD3,0xB6,0xB5,0x3E,0xB9,0xFB,0x48,0xF9,0xCB,0x04,
MiniTLS 0:60de3ce23ca9 19 0x50,0xC0,0xB0,0x54,0x00,0x85,0xE6,0x35,0x0B,0x0C,0x8C,0x76,0x01,0x86,0x6D,0xA3,
MiniTLS 0:60de3ce23ca9 20 0x3A,0xCD,0xF4,0x67,0xF4,0x2A,0x1D,0x80,0xE6,0xF5,0x43,0xA8,0x05,0x6B,0x2E,0xA8,
MiniTLS 0:60de3ce23ca9 21 0x22,0x21,0xA6,0xA6,0xE0,0x0D,0x96,0x2D,0x10,0x75,0x11,0x57,0xE8,0x23,0xEC,0x8E,
MiniTLS 0:60de3ce23ca9 22 0x1E,0xAD,0x3C,0x26,0xC4,0x57,0x9F,0xE5,0x33,0x3D,0x66,0xF4,0x12,0x6F,0xFF,0x10,
MiniTLS 0:60de3ce23ca9 23 0x87,0xBC,0xCF,0x4D,0xFB,0xF9,0xF1,0xF4,0x8D,0x78,0x1A,0x49,0x7F,0xFB,0x8F,0x3C,
MiniTLS 0:60de3ce23ca9 24 0x6E,0x3E,0x4F,0xDD,0x0A,0xF6,0xC2,0x5F,0xA6,0xDC,0x11,0x89,0xF5,0x10,0x7B,0x00,
MiniTLS 0:60de3ce23ca9 25 0x1A,0x83,0x0B,0xDC,0xF5,0xAE,0x7A,0xB3,0x63,0xD3,0x97,0x71,0xD3,0x27,0x83,0x5D,
MiniTLS 0:60de3ce23ca9 26 0xCA,0x7F,0x44,0x6C,0xDC,0x6F,0x46,0x3D,0x0E,0x6E,0x86,0x31,0xCB,0xF6,0x08,0x18,
MiniTLS 0:60de3ce23ca9 27 0xD6,0x2E,0x45,0xCB,0x9E,0x93,0xCB,0x28,0xA6,0x11,0xE6,0x34,0x07,0x2E,0x06,0x26,
MiniTLS 0:60de3ce23ca9 28 0x34,0xCC,0xD5,0xD2,0xAE,0x6C,0x91,0x1D,0x88,0xF3,0xD2,0xDF,0x7E,0x01,0x4E,0xA4,
MiniTLS 0:60de3ce23ca9 29 0xBF,0x2F,0x7B,0x5B,0xAB,0xB7,0xFA,0xDE,0x7A,0xE9,0x0B,0x6F,0x8D,0x63,0x14,0x70,
MiniTLS 0:60de3ce23ca9 30 0x17,0x02,0x03,0x01,0x00,0x01,
MiniTLS 0:60de3ce23ca9 31 };
MiniTLS 0:60de3ce23ca9 32
MiniTLS 0:60de3ce23ca9 33 const uint8_t certificate[] = {
MiniTLS 0:60de3ce23ca9 34 0x30,0x82,0x05,0x23,0x30,0x82,0x04,0x0B,0xA0,0x03,0x02,0x01,0x02,0x02,0x10,0x4B,
MiniTLS 0:60de3ce23ca9 35 0x69,0xC7,0xD9,0x89,0xC9,0x38,0xA7,0xCD,0x73,0x3A,0x96,0xB0,0x62,0xDD,0xFC,0x30,
MiniTLS 0:60de3ce23ca9 36 0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,0x05,0x00,0x30,0x81,
MiniTLS 0:60de3ce23ca9 37 0xBC,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x17,
MiniTLS 0:60de3ce23ca9 38 0x30,0x15,0x06,0x03,0x55,0x04,0x0A,0x13,0x0E,0x56,0x65,0x72,0x69,0x53,0x69,0x67,
MiniTLS 0:60de3ce23ca9 39 0x6E,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x1F,0x30,0x1D,0x06,0x03,0x55,0x04,0x0B,
MiniTLS 0:60de3ce23ca9 40 0x13,0x16,0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x54,0x72,0x75,0x73,0x74,
MiniTLS 0:60de3ce23ca9 41 0x20,0x4E,0x65,0x74,0x77,0x6F,0x72,0x6B,0x31,0x3B,0x30,0x39,0x06,0x03,0x55,0x04,
MiniTLS 0:60de3ce23ca9 42 0x0B,0x13,0x32,0x54,0x65,0x72,0x6D,0x73,0x20,0x6F,0x66,0x20,0x75,0x73,0x65,0x20,
MiniTLS 0:60de3ce23ca9 43 0x61,0x74,0x20,0x68,0x74,0x74,0x70,0x73,0x3A,0x2F,0x2F,0x77,0x77,0x77,0x2E,0x76,
MiniTLS 0:60de3ce23ca9 44 0x65,0x72,0x69,0x73,0x69,0x67,0x6E,0x2E,0x63,0x6F,0x6D,0x2F,0x72,0x70,0x61,0x20,
MiniTLS 0:60de3ce23ca9 45 0x28,0x63,0x29,0x31,0x30,0x31,0x36,0x30,0x34,0x06,0x03,0x55,0x04,0x03,0x13,0x2D,
MiniTLS 0:60de3ce23ca9 46 0x56,0x65,0x72,0x69,0x53,0x69,0x67,0x6E,0x20,0x43,0x6C,0x61,0x73,0x73,0x20,0x33,
MiniTLS 0:60de3ce23ca9 47 0x20,0x49,0x6E,0x74,0x65,0x72,0x6E,0x61,0x74,0x69,0x6F,0x6E,0x61,0x6C,0x20,0x53,
MiniTLS 0:60de3ce23ca9 48 0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x41,0x20,0x2D,0x20,0x47,0x33,0x30,0x1E,0x17,
MiniTLS 0:60de3ce23ca9 49 0x0D,0x31,0x34,0x30,0x34,0x30,0x39,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x17,0x0D,
MiniTLS 0:60de3ce23ca9 50 0x31,0x34,0x30,0x37,0x32,0x36,0x32,0x33,0x35,0x39,0x35,0x39,0x5A,0x30,0x6E,0x31,
MiniTLS 0:60de3ce23ca9 51 0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x47,0x42,0x31,0x17,0x30,0x15,
MiniTLS 0:60de3ce23ca9 52 0x06,0x03,0x55,0x04,0x08,0x13,0x0E,0x43,0x61,0x6D,0x62,0x72,0x69,0x64,0x67,0x65,
MiniTLS 0:60de3ce23ca9 53 0x73,0x68,0x69,0x72,0x65,0x31,0x12,0x30,0x10,0x06,0x03,0x55,0x04,0x07,0x14,0x09,
MiniTLS 0:60de3ce23ca9 54 0x43,0x61,0x6D,0x62,0x72,0x69,0x64,0x67,0x65,0x31,0x10,0x30,0x0E,0x06,0x03,0x55,
MiniTLS 0:60de3ce23ca9 55 0x04,0x0A,0x14,0x07,0x41,0x52,0x4D,0x20,0x4C,0x74,0x64,0x31,0x0D,0x30,0x0B,0x06,
MiniTLS 0:60de3ce23ca9 56 0x03,0x55,0x04,0x0B,0x14,0x04,0x41,0x44,0x49,0x54,0x31,0x11,0x30,0x0F,0x06,0x03,
MiniTLS 0:60de3ce23ca9 57 0x55,0x04,0x03,0x14,0x08,0x6D,0x62,0x65,0x64,0x2E,0x6F,0x72,0x67,0x30,0x82,0x01,
MiniTLS 0:60de3ce23ca9 58 0x22,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,
MiniTLS 0:60de3ce23ca9 59 0x03,0x82,0x01,0x0F,0x00,0x30,0x82,0x01,0x0A,0x02,0x82,0x01,0x01,0x00,0xEC,0x4F,
MiniTLS 0:60de3ce23ca9 60 0x55,0x0A,0xD8,0xB1,0x6D,0xA1,0xB1,0x9F,0x1C,0xD8,0x93,0xE9,0x64,0x64,0x77,0x14,
MiniTLS 0:60de3ce23ca9 61 0x28,0x53,0x70,0xD6,0x4F,0xCF,0x99,0x3A,0x38,0x36,0xF9,0x7B,0x77,0xAB,0x0C,0x1D,
MiniTLS 0:60de3ce23ca9 62 0xE0,0x5B,0x55,0x93,0x09,0x34,0x31,0x8A,0x98,0xF0,0x98,0xB8,0x29,0xC2,0xF8,0x1E,
MiniTLS 0:60de3ce23ca9 63 0xFF,0xD8,0x8F,0xD5,0x91,0x4C,0xD6,0x32,0xF2,0x67,0x33,0x79,0xF4,0x4E,0x92,0xD8,
MiniTLS 0:60de3ce23ca9 64 0x75,0xD3,0x2F,0xD3,0xB6,0xB5,0x3E,0xB9,0xFB,0x48,0xF9,0xCB,0x04,0x50,0xC0,0xB0,
MiniTLS 0:60de3ce23ca9 65 0x54,0x00,0x85,0xE6,0x35,0x0B,0x0C,0x8C,0x76,0x01,0x86,0x6D,0xA3,0x3A,0xCD,0xF4,
MiniTLS 0:60de3ce23ca9 66 0x67,0xF4,0x2A,0x1D,0x80,0xE6,0xF5,0x43,0xA8,0x05,0x6B,0x2E,0xA8,0x22,0x21,0xA6,
MiniTLS 0:60de3ce23ca9 67 0xA6,0xE0,0x0D,0x96,0x2D,0x10,0x75,0x11,0x57,0xE8,0x23,0xEC,0x8E,0x1E,0xAD,0x3C,
MiniTLS 0:60de3ce23ca9 68 0x26,0xC4,0x57,0x9F,0xE5,0x33,0x3D,0x66,0xF4,0x12,0x6F,0xFF,0x10,0x87,0xBC,0xCF,
MiniTLS 0:60de3ce23ca9 69 0x4D,0xFB,0xF9,0xF1,0xF4,0x8D,0x78,0x1A,0x49,0x7F,0xFB,0x8F,0x3C,0x6E,0x3E,0x4F,
MiniTLS 0:60de3ce23ca9 70 0xDD,0x0A,0xF6,0xC2,0x5F,0xA6,0xDC,0x11,0x89,0xF5,0x10,0x7B,0x00,0x1A,0x83,0x0B,
MiniTLS 0:60de3ce23ca9 71 0xDC,0xF5,0xAE,0x7A,0xB3,0x63,0xD3,0x97,0x71,0xD3,0x27,0x83,0x5D,0xCA,0x7F,0x44,
MiniTLS 0:60de3ce23ca9 72 0x6C,0xDC,0x6F,0x46,0x3D,0x0E,0x6E,0x86,0x31,0xCB,0xF6,0x08,0x18,0xD6,0x2E,0x45,
MiniTLS 0:60de3ce23ca9 73 0xCB,0x9E,0x93,0xCB,0x28,0xA6,0x11,0xE6,0x34,0x07,0x2E,0x06,0x26,0x34,0xCC,0xD5,
MiniTLS 0:60de3ce23ca9 74 0xD2,0xAE,0x6C,0x91,0x1D,0x88,0xF3,0xD2,0xDF,0x7E,0x01,0x4E,0xA4,0xBF,0x2F,0x7B,
MiniTLS 0:60de3ce23ca9 75 0x5B,0xAB,0xB7,0xFA,0xDE,0x7A,0xE9,0x0B,0x6F,0x8D,0x63,0x14,0x70,0x17,0x02,0x03,
MiniTLS 0:60de3ce23ca9 76 0x01,0x00,0x01,0xA3,0x82,0x01,0x6C,0x30,0x82,0x01,0x68,0x30,0x13,0x06,0x03,0x55,
MiniTLS 0:60de3ce23ca9 77 0x1D,0x11,0x04,0x0C,0x30,0x0A,0x82,0x08,0x6D,0x62,0x65,0x64,0x2E,0x6F,0x72,0x67,
MiniTLS 0:60de3ce23ca9 78 0x30,0x09,0x06,0x03,0x55,0x1D,0x13,0x04,0x02,0x30,0x00,0x30,0x0E,0x06,0x03,0x55,
MiniTLS 0:60de3ce23ca9 79 0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x05,0xA0,0x30,0x28,0x06,0x03,0x55,
MiniTLS 0:60de3ce23ca9 80 0x1D,0x25,0x04,0x21,0x30,0x1F,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x01,
MiniTLS 0:60de3ce23ca9 81 0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x03,0x02,0x06,0x09,0x60,0x86,0x48,0x01,
MiniTLS 0:60de3ce23ca9 82 0x86,0xF8,0x42,0x04,0x01,0x30,0x65,0x06,0x03,0x55,0x1D,0x20,0x04,0x5E,0x30,0x5C,
MiniTLS 0:60de3ce23ca9 83 0x30,0x5A,0x06,0x0A,0x60,0x86,0x48,0x01,0x86,0xF8,0x45,0x01,0x07,0x36,0x30,0x4C,
MiniTLS 0:60de3ce23ca9 84 0x30,0x23,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x02,0x01,0x16,0x17,0x68,0x74,
MiniTLS 0:60de3ce23ca9 85 0x74,0x70,0x73,0x3A,0x2F,0x2F,0x64,0x2E,0x73,0x79,0x6D,0x63,0x62,0x2E,0x63,0x6F,
MiniTLS 0:60de3ce23ca9 86 0x6D,0x2F,0x63,0x70,0x73,0x30,0x25,0x06,0x08,0x2B,0x06,0x01,0x05,0x05,0x07,0x02,
MiniTLS 0:60de3ce23ca9 87 0x02,0x30,0x19,0x1A,0x17,0x68,0x74,0x74,0x70,0x73,0x3A,0x2F,0x2F,0x64,0x2E,0x73,
MiniTLS 0:60de3ce23ca9 88 0x79,0x6D,0x63,0x62,0x2E,0x63,0x6F,0x6D,0x2F,0x72,0x70,0x61,0x30,0x1F,0x06,0x03,
MiniTLS 0:60de3ce23ca9 89 0x55,0x1D,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0xD7,0x9B,0x7C,0xD8,0x22,0xA0,0x15,
MiniTLS 0:60de3ce23ca9 90 0xF7,0xDD,0xAD,0x5F,0xCE,0x29,0x9B,0x58,0xC3,0xBC,0x46,0x00,0xB5,0x30,0x2B,0x06,
MiniTLS 0:60de3ce23ca9 91 0x03,0x55,0x1D,0x1F,0x04,0x24,0x30,0x22,0x30,0x20,0xA0,0x1E,0xA0,0x1C,0x86,0x1A,
MiniTLS 0:60de3ce23ca9 92 0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,0x73,0x65,0x2E,0x73,0x79,0x6D,0x63,0x62,0x2E,
MiniTLS 0:60de3ce23ca9 93 0x63,0x6F,0x6D,0x2F,0x73,0x65,0x2E,0x63,0x72,0x6C,0x30,0x57,0x06,0x08,0x2B,0x06,
MiniTLS 0:60de3ce23ca9 94 0x01,0x05,0x05,0x07,0x01,0x01,0x04,0x4B,0x30,0x49,0x30,0x1F,0x06,0x08,0x2B,0x06,
MiniTLS 0:60de3ce23ca9 95 0x01,0x05,0x05,0x07,0x30,0x01,0x86,0x13,0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,0x73,
MiniTLS 0:60de3ce23ca9 96 0x65,0x2E,0x73,0x79,0x6D,0x63,0x64,0x2E,0x63,0x6F,0x6D,0x30,0x26,0x06,0x08,0x2B,
MiniTLS 0:60de3ce23ca9 97 0x06,0x01,0x05,0x05,0x07,0x30,0x02,0x86,0x1A,0x68,0x74,0x74,0x70,0x3A,0x2F,0x2F,
MiniTLS 0:60de3ce23ca9 98 0x73,0x65,0x2E,0x73,0x79,0x6D,0x63,0x62,0x2E,0x63,0x6F,0x6D,0x2F,0x73,0x65,0x2E,
MiniTLS 0:60de3ce23ca9 99 0x63,0x72,0x74,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,
MiniTLS 0:60de3ce23ca9 100 0x05,0x00,0x03,0x82,0x01,0x01,0x00,0x04,0x4E,0x6B,0xA6,0x99,0x45,0x71,0xF2,0xDE,
MiniTLS 0:60de3ce23ca9 101 0x9B,0xAC,0x92,0x05,0xE5,0x9E,0xF3,0x24,0x64,0x8F,0x79,0x0E,0x26,0x1D,0xD2,0x7F,
MiniTLS 0:60de3ce23ca9 102 0x54,0x31,0xFA,0xB5,0xFC,0x2B,0x7C,0x6D,0x7E,0x59,0x97,0xBC,0xF8,0x72,0x09,0xF6,
MiniTLS 0:60de3ce23ca9 103 0xB1,0xF0,0xC8,0x5F,0xC6,0xE0,0x44,0x81,0x1A,0xCC,0x5B,0x3A,0xC3,0x89,0xD6,0x4F,
MiniTLS 0:60de3ce23ca9 104 0xB9,0x51,0xBC,0xD2,0xA4,0x9D,0xD4,0x95,0xEF,0x72,0x14,0x16,0x01,0xF4,0x98,0xDC,
MiniTLS 0:60de3ce23ca9 105 0xB3,0x42,0x09,0x35,0x9B,0xCF,0xFB,0xBB,0xA3,0x6A,0x28,0xB4,0xB6,0xFD,0xBB,0x93,
MiniTLS 0:60de3ce23ca9 106 0x2A,0xA0,0xA7,0xA5,0x30,0xC0,0x12,0x20,0xCC,0x15,0x48,0xB1,0xEC,0x00,0xB8,0xA7,
MiniTLS 0:60de3ce23ca9 107 0x8D,0x26,0xE3,0xBB,0x5C,0x4F,0x31,0x25,0x11,0x10,0x8C,0x72,0xC7,0x60,0x4F,0xFA,
MiniTLS 0:60de3ce23ca9 108 0x5F,0x8A,0x6E,0x65,0xF2,0xE0,0xE5,0x09,0x4F,0x0F,0x34,0x11,0x67,0xE7,0x7F,0x62,
MiniTLS 0:60de3ce23ca9 109 0x2C,0xFE,0x34,0x5A,0xED,0x41,0x01,0x62,0xBF,0x22,0xD5,0x0E,0x8D,0xC5,0x8B,0xB3,
MiniTLS 0:60de3ce23ca9 110 0x51,0xFE,0x7C,0xEC,0x0E,0x4F,0x9A,0x20,0xD3,0x4E,0x07,0x4A,0xBB,0x4F,0x5C,0x2E,
MiniTLS 0:60de3ce23ca9 111 0xA1,0x27,0x0C,0x95,0xD4,0x28,0xFD,0xB3,0xE7,0xD5,0xC9,0xEB,0xC1,0x1E,0x56,0x17,
MiniTLS 0:60de3ce23ca9 112 0x76,0x54,0x1E,0xE3,0xC7,0x8B,0x30,0x2D,0x52,0x2F,0x52,0x0D,0xE7,0x4D,0xFD,0x15,
MiniTLS 0:60de3ce23ca9 113 0xDC,0x86,0x8E,0x5B,0xF1,0x27,0xA3,0x31,0xDF,0x8B,0x57,0x55,0xBB,0x04,0xA5,0x4B,
MiniTLS 0:60de3ce23ca9 114 0x79,0xB3,0xBA,0xA4,0x3A,0xE0,0x98,0x73,0xEE,0xF3,0x74,0xA3,0x97,0xDC,0x8D,0x98,
MiniTLS 0:60de3ce23ca9 115 0x17,0xFB,0x14,0xF6,0xC6,0x2C,0x5A,0x46,0xAC,0xA9,0x43,0xAE,0xDE,0xEB,0x9F,0xC9,
MiniTLS 0:60de3ce23ca9 116 0x58,0xCE,0xC6,0x17,0x12,0xF4,0xC6,
MiniTLS 0:60de3ce23ca9 117 };
MiniTLS 0:60de3ce23ca9 118
MiniTLS 0:60de3ce23ca9 119 int main()
MiniTLS 0:60de3ce23ca9 120 {
MiniTLS 0:60de3ce23ca9 121 Serial pc(USBTX, USBRX);
MiniTLS 0:60de3ce23ca9 122 pc.baud(115200);
MiniTLS 0:60de3ce23ca9 123
MiniTLS 0:60de3ce23ca9 124 miniTLS.init();
MiniTLS 0:60de3ce23ca9 125
MiniTLS 0:60de3ce23ca9 126 //Deterministic but this is an example!
MiniTLS 0:60de3ce23ca9 127 for(int i = 0; i < 32; i++)
MiniTLS 0:60de3ce23ca9 128 {
MiniTLS 0:60de3ce23ca9 129 uint32_t ticks = us_ticker_read();
MiniTLS 0:60de3ce23ca9 130 miniTLS.feedPRNG((uint8_t*)&ticks, sizeof(uint32_t));
MiniTLS 0:60de3ce23ca9 131 }
MiniTLS 0:60de3ce23ca9 132
MiniTLS 0:60de3ce23ca9 133 miniTLS.addCertificate(certificate, sizeof(certificate), pub_key, sizeof(pub_key));
MiniTLS 0:60de3ce23ca9 134
MiniTLS 0:60de3ce23ca9 135 eth.init(); //Use DHCP
MiniTLS 0:60de3ce23ca9 136
MiniTLS 0:60de3ce23ca9 137 int ret = eth.connect();
MiniTLS 0:60de3ce23ca9 138 if(ret)
MiniTLS 0:60de3ce23ca9 139 {
MiniTLS 0:60de3ce23ca9 140 printf("connect() returned %d\r\n", ret);
MiniTLS 0:60de3ce23ca9 141 }
MiniTLS 0:60de3ce23ca9 142
MiniTLS 0:60de3ce23ca9 143 //GET data
MiniTLS 0:60de3ce23ca9 144 printf("Trying to fetch page...\r\n");
MiniTLS 0:60de3ce23ca9 145 ret = http.get("https://mbed.org/media/uploads/donatien/hello.txt", str, 128);
MiniTLS 0:60de3ce23ca9 146 if (!ret)
MiniTLS 0:60de3ce23ca9 147 {
MiniTLS 0:60de3ce23ca9 148 printf("Page fetched successfully - read %d characters\r\n", strlen(str));
MiniTLS 0:60de3ce23ca9 149 printf("Result: %s\r\n", str);
MiniTLS 0:60de3ce23ca9 150 }
MiniTLS 0:60de3ce23ca9 151 else
MiniTLS 0:60de3ce23ca9 152 {
MiniTLS 0:60de3ce23ca9 153 printf("Error - ret = %d - HTTP return code = %d\r\n", ret, http.getHTTPResponseCode());
MiniTLS 0:60de3ce23ca9 154 }
MiniTLS 0:60de3ce23ca9 155
MiniTLS 0:60de3ce23ca9 156 eth.disconnect();
MiniTLS 0:60de3ce23ca9 157
MiniTLS 0:60de3ce23ca9 158 while(1) {
MiniTLS 0:60de3ce23ca9 159 }
MiniTLS 0:60de3ce23ca9 160 }