Skip to content

Commit 5a95bc9

Browse files
authored
Merge pull request #370 from pennam/esp32_certs
ESP32: enable TLS and add server cert
2 parents dc50659 + 1e78257 commit 5a95bc9

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

src/ArduinoIoTCloudTCP.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
#include "tls/utility/CryptoUtil.h"
4040
#endif
4141

42+
#ifdef BOARD_HAS_SECRET_KEY
43+
#include "tls/AIoTCUPCert.h"
44+
#endif
45+
4246
#if OTA_ENABLED
4347
#include "utility/ota/OTA.h"
4448
#endif
@@ -172,7 +176,11 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
172176
#elif defined(BOARD_HAS_SE050)
173177
_sslClient.appendCustomCACert(AIoTSSCert);
174178
#elif defined(BOARD_ESP)
179+
#if defined(ARDUINO_ARCH_ESP8266)
175180
_sslClient.setInsecure();
181+
#else
182+
_sslClient.setCACert(AAIoTUPCert);
183+
#endif
176184
#endif
177185

178186
_mqttClient.setClient(_sslClient);

src/tls/AIoTCUPCert.h

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
This file is part of ArduinoIoTBearSSL.
3+
4+
Copyright 2019 ARDUINO SA (http://www.arduino.cc/)
5+
6+
This software is released under the GNU General Public License version 3,
7+
which covers the main part of ArduinoIoTBearSSL.
8+
The terms of this license can be found at:
9+
https://www.gnu.org/licenses/gpl-3.0.en.html
10+
11+
You can be released from the requirements of the above licenses by purchasing
12+
a commercial license. Buying such a license is mandatory if you want to modify or
13+
otherwise use the software for commercial activities involving the Arduino
14+
software without disclosing the source code of your own applications. To purchase
15+
a commercial license, send an email to [email protected].
16+
17+
*/
18+
19+
#ifndef _AIOTC_UP_CERT_H_
20+
#define _AIOTC_UP_CERT_H_
21+
22+
/******************************************************************************
23+
* INCLUDE
24+
******************************************************************************/
25+
26+
#include <AIoTC_Config.h>
27+
#ifdef BOARD_HAS_SECRET_KEY
28+
29+
/******************************************************************************
30+
* CONSTANTS
31+
******************************************************************************/
32+
33+
//https://www.amazontrust.com/repository/Amazon-RSA-2048-M01.pem
34+
static const char AAIoTUPCert[] =
35+
"-----BEGIN CERTIFICATE-----\n"
36+
"MIIEXjCCA0agAwIBAgITB3MSOAudZoijOx7Zv5zNpo4ODzANBgkqhkiG9w0BAQsF\n"
37+
"ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6\n"
38+
"b24gUm9vdCBDQSAxMB4XDTIyMDgyMzIyMjEyOFoXDTMwMDgyMzIyMjEyOFowPDEL\n"
39+
"MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEcMBoGA1UEAxMTQW1hem9uIFJT\n"
40+
"QSAyMDQ4IE0wMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOtxLKnL\n"
41+
"H4gokjIwr4pXD3i3NyWVVYesZ1yX0yLI2qIUZ2t88Gfa4gMqs1YSXca1R/lnCKeT\n"
42+
"epWSGA+0+fkQNpp/L4C2T7oTTsddUx7g3ZYzByDTlrwS5HRQQqEFE3O1T5tEJP4t\n"
43+
"f+28IoXsNiEzl3UGzicYgtzj2cWCB41eJgEmJmcf2T8TzzK6a614ZPyq/w4CPAff\n"
44+
"nAV4coz96nW3AyiE2uhuB4zQUIXvgVSycW7sbWLvj5TDXunEpNCRwC4kkZjK7rol\n"
45+
"jtT2cbb7W2s4Bkg3R42G3PLqBvt2N32e/0JOTViCk8/iccJ4sXqrS1uUN4iB5Nmv\n"
46+
"JK74csVl+0u0UecCAwEAAaOCAVowggFWMBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYD\n"
47+
"VR0PAQH/BAQDAgGGMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAdBgNV\n"
48+
"HQ4EFgQUgbgOY4qJEhjl+js7UJWf5uWQE4UwHwYDVR0jBBgwFoAUhBjMhTTsvAyU\n"
49+
"lC4IWZzHshBOCggwewYIKwYBBQUHAQEEbzBtMC8GCCsGAQUFBzABhiNodHRwOi8v\n"
50+
"b2NzcC5yb290Y2ExLmFtYXpvbnRydXN0LmNvbTA6BggrBgEFBQcwAoYuaHR0cDov\n"
51+
"L2NydC5yb290Y2ExLmFtYXpvbnRydXN0LmNvbS9yb290Y2ExLmNlcjA/BgNVHR8E\n"
52+
"ODA2MDSgMqAwhi5odHRwOi8vY3JsLnJvb3RjYTEuYW1hem9udHJ1c3QuY29tL3Jv\n"
53+
"b3RjYTEuY3JsMBMGA1UdIAQMMAowCAYGZ4EMAQIBMA0GCSqGSIb3DQEBCwUAA4IB\n"
54+
"AQCtAN4CBSMuBjJitGuxlBbkEUDeK/pZwTXv4KqPK0G50fOHOQAd8j21p0cMBgbG\n"
55+
"kfMHVwLU7b0XwZCav0h1ogdPMN1KakK1DT0VwA/+hFvGPJnMV1Kx2G4S1ZaSk0uU\n"
56+
"5QfoiYIIano01J5k4T2HapKQmmOhS/iPtuo00wW+IMLeBuKMn3OLn005hcrOGTad\n"
57+
"hcmeyfhQP7Z+iKHvyoQGi1C0ClymHETx/chhQGDyYSWqB/THwnN15AwLQo0E5V9E\n"
58+
"SJlbe4mBlqeInUsNYugExNf+tOiybcrswBy8OFsd34XOW3rjSUtsuafd9AWySa3h\n"
59+
"xRRrwszrzX/WWGm6wyB+f7C4\n"
60+
"-----END CERTIFICATE-----\n";
61+
62+
#endif /* #ifdef BOARD_HAS_SECRET_KEY */
63+
64+
#endif /* _AIOTC_UP_CERT_H_ */

0 commit comments

Comments
 (0)