HTTP and HTTPS library for Mbed OS 5
Dependents: RZ_A2M_Mbed_samples_20201012 RZ_A2M_Mbed_samples
TESTS/COMMON/test_setup.h@40:8fe3b866f1f4, 2020-09-16 (annotated)
- Committer:
- RyoheiHagimoto@os.mbed.com
- Date:
- Wed Sep 16 14:40:45 2020 +0900
- Revision:
- 40:8fe3b866f1f4
- Parent:
- 34:6daf67a96a91
Modified some API for Mbed OS 6.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jan Jongboom |
34:6daf67a96a91 | 1 | #ifndef _MBED_HTTP_TEST_SETUP_H_ |
Jan Jongboom |
34:6daf67a96a91 | 2 | #define _MBED_HTTP_TEST_SETUP_H_ |
Jan Jongboom |
34:6daf67a96a91 | 3 | |
Jan Jongboom |
34:6daf67a96a91 | 4 | #include "mbed.h" |
Jan Jongboom |
34:6daf67a96a91 | 5 | #include "NetworkInterface.h" |
Jan Jongboom |
34:6daf67a96a91 | 6 | |
Jan Jongboom |
34:6daf67a96a91 | 7 | /** |
Jan Jongboom |
34:6daf67a96a91 | 8 | * Connect to the network using the default networking interface, |
Jan Jongboom |
34:6daf67a96a91 | 9 | * you can also swap this out with a driver for a different networking interface |
Jan Jongboom |
34:6daf67a96a91 | 10 | * if you use WiFi: see mbed_app.json for the credentials |
Jan Jongboom |
34:6daf67a96a91 | 11 | */ |
Jan Jongboom |
34:6daf67a96a91 | 12 | NetworkInterface *connect_to_default_network_interface() { |
Jan Jongboom |
34:6daf67a96a91 | 13 | NetworkInterface* network = NetworkInterface::get_default_instance(); |
Jan Jongboom |
34:6daf67a96a91 | 14 | |
Jan Jongboom |
34:6daf67a96a91 | 15 | if (!network) { |
Jan Jongboom |
34:6daf67a96a91 | 16 | return NULL; |
Jan Jongboom |
34:6daf67a96a91 | 17 | } |
Jan Jongboom |
34:6daf67a96a91 | 18 | |
Jan Jongboom |
34:6daf67a96a91 | 19 | nsapi_error_t connect_status = network->connect(); |
Jan Jongboom |
34:6daf67a96a91 | 20 | |
Jan Jongboom |
34:6daf67a96a91 | 21 | if (connect_status != NSAPI_ERROR_OK) { |
Jan Jongboom |
34:6daf67a96a91 | 22 | return NULL; |
Jan Jongboom |
34:6daf67a96a91 | 23 | } |
Jan Jongboom |
34:6daf67a96a91 | 24 | |
Jan Jongboom |
34:6daf67a96a91 | 25 | return network; |
Jan Jongboom |
34:6daf67a96a91 | 26 | } |
Jan Jongboom |
34:6daf67a96a91 | 27 | |
Jan Jongboom |
34:6daf67a96a91 | 28 | |
Jan Jongboom |
34:6daf67a96a91 | 29 | /* List of trusted root CA certificates |
Jan Jongboom |
34:6daf67a96a91 | 30 | * |
Jan Jongboom |
34:6daf67a96a91 | 31 | * - Amazon, the CA for os.mbed.com |
Jan Jongboom |
34:6daf67a96a91 | 32 | * - Let's Encrypt, the CA for httpbin.org |
Jan Jongboom |
34:6daf67a96a91 | 33 | * - Comodo, the CA for reqres.in |
Jan Jongboom |
34:6daf67a96a91 | 34 | * |
Jan Jongboom |
34:6daf67a96a91 | 35 | * To add more root certificates, just concatenate them. |
Jan Jongboom |
34:6daf67a96a91 | 36 | */ |
Jan Jongboom |
34:6daf67a96a91 | 37 | const char SSL_CA_PEM[] = "-----BEGIN CERTIFICATE-----\n" |
Jan Jongboom |
34:6daf67a96a91 | 38 | "MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF\n" |
Jan Jongboom |
34:6daf67a96a91 | 39 | "ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n" |
Jan Jongboom |
34:6daf67a96a91 | 40 | "b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL\n" |
Jan Jongboom |
34:6daf67a96a91 | 41 | "MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv\n" |
Jan Jongboom |
34:6daf67a96a91 | 42 | "b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj\n" |
Jan Jongboom |
34:6daf67a96a91 | 43 | "ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM\n" |
Jan Jongboom |
34:6daf67a96a91 | 44 | "9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw\n" |
Jan Jongboom |
34:6daf67a96a91 | 45 | "IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6\n" |
Jan Jongboom |
34:6daf67a96a91 | 46 | "VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L\n" |
Jan Jongboom |
34:6daf67a96a91 | 47 | "93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm\n" |
Jan Jongboom |
34:6daf67a96a91 | 48 | "jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC\n" |
Jan Jongboom |
34:6daf67a96a91 | 49 | "AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA\n" |
Jan Jongboom |
34:6daf67a96a91 | 50 | "A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI\n" |
Jan Jongboom |
34:6daf67a96a91 | 51 | "U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs\n" |
Jan Jongboom |
34:6daf67a96a91 | 52 | "N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv\n" |
Jan Jongboom |
34:6daf67a96a91 | 53 | "o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU\n" |
Jan Jongboom |
34:6daf67a96a91 | 54 | "5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy\n" |
Jan Jongboom |
34:6daf67a96a91 | 55 | "rqXRfboQnoZsG4q5WTP468SQvvG5\n" |
Jan Jongboom |
34:6daf67a96a91 | 56 | "-----END CERTIFICATE-----\n" |
Jan Jongboom |
34:6daf67a96a91 | 57 | "-----BEGIN CERTIFICATE-----\n" |
Jan Jongboom |
34:6daf67a96a91 | 58 | "MIIEkjCCA3qgAwIBAgIQCgFBQgAAAVOFc2oLheynCDANBgkqhkiG9w0BAQsFADA/\n" |
Jan Jongboom |
34:6daf67a96a91 | 59 | "MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT\n" |
Jan Jongboom |
34:6daf67a96a91 | 60 | "DkRTVCBSb290IENBIFgzMB4XDTE2MDMxNzE2NDA0NloXDTIxMDMxNzE2NDA0Nlow\n" |
Jan Jongboom |
34:6daf67a96a91 | 61 | "SjELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUxldCdzIEVuY3J5cHQxIzAhBgNVBAMT\n" |
Jan Jongboom |
34:6daf67a96a91 | 62 | "GkxldCdzIEVuY3J5cHQgQXV0aG9yaXR5IFgzMIIBIjANBgkqhkiG9w0BAQEFAAOC\n" |
Jan Jongboom |
34:6daf67a96a91 | 63 | "AQ8AMIIBCgKCAQEAnNMM8FrlLke3cl03g7NoYzDq1zUmGSXhvb418XCSL7e4S0EF\n" |
Jan Jongboom |
34:6daf67a96a91 | 64 | "q6meNQhY7LEqxGiHC6PjdeTm86dicbp5gWAf15Gan/PQeGdxyGkOlZHP/uaZ6WA8\n" |
Jan Jongboom |
34:6daf67a96a91 | 65 | "SMx+yk13EiSdRxta67nsHjcAHJyse6cF6s5K671B5TaYucv9bTyWaN8jKkKQDIZ0\n" |
Jan Jongboom |
34:6daf67a96a91 | 66 | "Z8h/pZq4UmEUEz9l6YKHy9v6Dlb2honzhT+Xhq+w3Brvaw2VFn3EK6BlspkENnWA\n" |
Jan Jongboom |
34:6daf67a96a91 | 67 | "a6xK8xuQSXgvopZPKiAlKQTGdMDQMc2PMTiVFrqoM7hD8bEfwzB/onkxEz0tNvjj\n" |
Jan Jongboom |
34:6daf67a96a91 | 68 | "/PIzark5McWvxI0NHWQWM6r6hCm21AvA2H3DkwIDAQABo4IBfTCCAXkwEgYDVR0T\n" |
Jan Jongboom |
34:6daf67a96a91 | 69 | "AQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYwfwYIKwYBBQUHAQEEczBxMDIG\n" |
Jan Jongboom |
34:6daf67a96a91 | 70 | "CCsGAQUFBzABhiZodHRwOi8vaXNyZy50cnVzdGlkLm9jc3AuaWRlbnRydXN0LmNv\n" |
Jan Jongboom |
34:6daf67a96a91 | 71 | "bTA7BggrBgEFBQcwAoYvaHR0cDovL2FwcHMuaWRlbnRydXN0LmNvbS9yb290cy9k\n" |
Jan Jongboom |
34:6daf67a96a91 | 72 | "c3Ryb290Y2F4My5wN2MwHwYDVR0jBBgwFoAUxKexpHsscfrb4UuQdf/EFWCFiRAw\n" |
Jan Jongboom |
34:6daf67a96a91 | 73 | "VAYDVR0gBE0wSzAIBgZngQwBAgEwPwYLKwYBBAGC3xMBAQEwMDAuBggrBgEFBQcC\n" |
Jan Jongboom |
34:6daf67a96a91 | 74 | "ARYiaHR0cDovL2Nwcy5yb290LXgxLmxldHNlbmNyeXB0Lm9yZzA8BgNVHR8ENTAz\n" |
Jan Jongboom |
34:6daf67a96a91 | 75 | "MDGgL6AthitodHRwOi8vY3JsLmlkZW50cnVzdC5jb20vRFNUUk9PVENBWDNDUkwu\n" |
Jan Jongboom |
34:6daf67a96a91 | 76 | "Y3JsMB0GA1UdDgQWBBSoSmpjBH3duubRObemRWXv86jsoTANBgkqhkiG9w0BAQsF\n" |
Jan Jongboom |
34:6daf67a96a91 | 77 | "AAOCAQEA3TPXEfNjWDjdGBX7CVW+dla5cEilaUcne8IkCJLxWh9KEik3JHRRHGJo\n" |
Jan Jongboom |
34:6daf67a96a91 | 78 | "uM2VcGfl96S8TihRzZvoroed6ti6WqEBmtzw3Wodatg+VyOeph4EYpr/1wXKtx8/\n" |
Jan Jongboom |
34:6daf67a96a91 | 79 | "wApIvJSwtmVi4MFU5aMqrSDE6ea73Mj2tcMyo5jMd6jmeWUHK8so/joWUoHOUgwu\n" |
Jan Jongboom |
34:6daf67a96a91 | 80 | "X4Po1QYz+3dszkDqMp4fklxBwXRsW10KXzPMTZ+sOPAveyxindmjkW8lGy+QsRlG\n" |
Jan Jongboom |
34:6daf67a96a91 | 81 | "PfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6\n" |
Jan Jongboom |
34:6daf67a96a91 | 82 | "KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg==\n" |
Jan Jongboom |
34:6daf67a96a91 | 83 | "-----END CERTIFICATE-----\n" |
Jan Jongboom |
34:6daf67a96a91 | 84 | "-----BEGIN CERTIFICATE-----\n" |
Jan Jongboom |
34:6daf67a96a91 | 85 | "MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTEL\n" |
Jan Jongboom |
34:6daf67a96a91 | 86 | "MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" |
Jan Jongboom |
34:6daf67a96a91 | 87 | "BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMT\n" |
Jan Jongboom |
34:6daf67a96a91 | 88 | "IkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwMzA2MDAw\n" |
Jan Jongboom |
34:6daf67a96a91 | 89 | "MDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdy\n" |
Jan Jongboom |
34:6daf67a96a91 | 90 | "ZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09N\n" |
Jan Jongboom |
34:6daf67a96a91 | 91 | "T0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlv\n" |
Jan Jongboom |
34:6daf67a96a91 | 92 | "biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSR\n" |
Jan Jongboom |
34:6daf67a96a91 | 93 | "FtSrYpn1PlILBs5BAH+X4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0J\n" |
Jan Jongboom |
34:6daf67a96a91 | 94 | "cfRK9ChQtP6IHG4/bC8vCVlbpVsLM5niwz2J+Wos77LTBumjQjBAMB0GA1UdDgQW\n" |
Jan Jongboom |
34:6daf67a96a91 | 95 | "BBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/\n" |
Jan Jongboom |
34:6daf67a96a91 | 96 | "BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VGFAkK+qDm\n" |
Jan Jongboom |
34:6daf67a96a91 | 97 | "fQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdv\n" |
Jan Jongboom |
34:6daf67a96a91 | 98 | "GDeAU/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=\n" |
Jan Jongboom |
34:6daf67a96a91 | 99 | "-----END CERTIFICATE-----\n"; |
Jan Jongboom |
34:6daf67a96a91 | 100 | |
Jan Jongboom |
34:6daf67a96a91 | 101 | #endif // MBED_HTTP_TEST_SETUP_H_ |