From 6fe42e39785bc722b3b605293900d30223567664 Mon Sep 17 00:00:00 2001 From: brentru Date: Wed, 12 May 2021 17:52:22 -0400 Subject: [PATCH 1/4] add root CA and setter --- src/wifi/AdafruitIO_ESP32.cpp | 6 +++--- src/wifi/AdafruitIO_ESP32.h | 30 ++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/wifi/AdafruitIO_ESP32.cpp b/src/wifi/AdafruitIO_ESP32.cpp index 04f79a7a..94dfafbe 100644 --- a/src/wifi/AdafruitIO_ESP32.cpp +++ b/src/wifi/AdafruitIO_ESP32.cpp @@ -5,8 +5,8 @@ * Please support Adafruit and open source hardware by purchasing * products from Adafruit! * - * Copyright (c) 2015-2016 Adafruit Industries - * Authors: Tony DiCola, Todd Treece + * Copyright (c) 2015-2021 Adafruit Industries + * Authors: Tony DiCola, Todd Treece, Brent Rubell * Licensed under the MIT license. * * All text above must be included in any redistribution. @@ -42,6 +42,7 @@ void AdafruitIO_ESP32::_connect() { delay(100); _status = AIO_NET_DISCONNECTED; } + _client.setCACert(_aio_root_ca); } /**************************************************************************/ @@ -55,7 +56,6 @@ void AdafruitIO_ESP32::_disconnect() { } aio_status_t AdafruitIO_ESP32::networkStatus() { - switch (WiFi.status()) { case WL_CONNECTED: return AIO_NET_CONNECTED; diff --git a/src/wifi/AdafruitIO_ESP32.h b/src/wifi/AdafruitIO_ESP32.h index 8bc4a92d..99d5ad5b 100644 --- a/src/wifi/AdafruitIO_ESP32.h +++ b/src/wifi/AdafruitIO_ESP32.h @@ -5,8 +5,8 @@ * Please support Adafruit and open source hardware by purchasing * products from Adafruit! * - * Copyright (c) 2015-2016 Adafruit Industries - * Authors: Tony DiCola, Todd Treece + * Copyright (c) 2015-2021 Adafruit Industries + * Authors: Tony DiCola, Todd Treece, Brent Rubell * Licensed under the MIT license. * * All text above must be included in any redistribution. @@ -42,6 +42,32 @@ class AdafruitIO_ESP32 : public AdafruitIO { const char *_pass; WiFiClientSecure *_client; + + // io.adafruit.com root CA + const char* _aio_root_ca = \ + "-----BEGIN CERTIFICATE-----\n" \ + "MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\n" \ + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" \ + "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\n" \ + "QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\n" \ + "MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n" \ + "b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG\n" \ + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB\n" \ + "CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97\n" \ + "nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt\n" \ + "43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P\n" \ + "T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4\n" \ + "gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO\n" \ + "BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR\n" \ + "TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw\n" \ + "DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr\n" \ + "hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg\n" \ + "06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF\n" \ + "PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\n" \ + "YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\n" \ + "CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\n" \ + "-----END CERTIFICATE-----\n"; + }; #endif // ESP32 From 49e4453a580478d81d1d8b00005a37e558a28722 Mon Sep 17 00:00:00 2001 From: brentru Date: Wed, 12 May 2021 17:54:15 -0400 Subject: [PATCH 2/4] ptr --- src/wifi/AdafruitIO_ESP32.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wifi/AdafruitIO_ESP32.cpp b/src/wifi/AdafruitIO_ESP32.cpp index 94dfafbe..f9d4c19c 100644 --- a/src/wifi/AdafruitIO_ESP32.cpp +++ b/src/wifi/AdafruitIO_ESP32.cpp @@ -42,7 +42,7 @@ void AdafruitIO_ESP32::_connect() { delay(100); _status = AIO_NET_DISCONNECTED; } - _client.setCACert(_aio_root_ca); + _client->setCACert(_aio_root_ca); } /**************************************************************************/ From f36b9136982c5d70f5d95bdedb69e6673f556895 Mon Sep 17 00:00:00 2001 From: brentru Date: Wed, 12 May 2021 17:57:00 -0400 Subject: [PATCH 3/4] bump lib --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 2610e18d..ff4e7559 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Adafruit IO Arduino -version=4.0.2 +version=4.1.0 author=Adafruit maintainer=Adafruit sentence=Arduino library to access Adafruit IO. From dd3b67a7bd631586cbc4651ccdc5a68217054906 Mon Sep 17 00:00:00 2001 From: brentru Date: Wed, 12 May 2021 18:10:31 -0400 Subject: [PATCH 4/4] clang format --- src/wifi/AdafruitIO_ESP32.h | 45 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/wifi/AdafruitIO_ESP32.h b/src/wifi/AdafruitIO_ESP32.h index 99d5ad5b..7c268476 100644 --- a/src/wifi/AdafruitIO_ESP32.h +++ b/src/wifi/AdafruitIO_ESP32.h @@ -44,30 +44,29 @@ class AdafruitIO_ESP32 : public AdafruitIO { WiFiClientSecure *_client; // io.adafruit.com root CA - const char* _aio_root_ca = \ - "-----BEGIN CERTIFICATE-----\n" \ - "MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\n" \ - "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" \ - "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\n" \ - "QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\n" \ - "MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\n" \ - "b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG\n" \ - "9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB\n" \ - "CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97\n" \ - "nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt\n" \ - "43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P\n" \ - "T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4\n" \ - "gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO\n" \ - "BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR\n" \ - "TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw\n" \ - "DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr\n" \ - "hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg\n" \ - "06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF\n" \ - "PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\n" \ - "YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\n" \ - "CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\n" \ + const char *_aio_root_ca = + "-----BEGIN CERTIFICATE-----\n" + "MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\n" + "MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\n" + "d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\n" + "QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\n" + "MRUwEwY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