28
28
#include " tls/utility/CryptoUtil.h"
29
29
#endif
30
30
31
+ #ifdef BOARD_HAS_SE050
32
+ #include " tls/AIoTCSSCert.h"
33
+ #include " tls/utility/CryptoUtil.h"
34
+ #endif
35
+
31
36
#ifdef BOARD_HAS_OFFLOADED_ECCX08
32
37
#include < ArduinoECCX08.h>
33
38
#include " tls/utility/CryptoUtil.h"
@@ -203,7 +208,7 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
203
208
_ota_img_sha256 = sha256_str;
204
209
#endif /* OTA_ENABLED */
205
210
206
- # ifdef BOARD_HAS_OFFLOADED_ECCX08
211
+ # if defined(BOARD_HAS_ECCX08) || defined( BOARD_HAS_OFFLOADED_ECCX08) || defined(BOARD_HAS_SE050)
207
212
if (!_crypto.begin ())
208
213
{
209
214
DEBUG_ERROR (" _crypto.begin() failed." );
@@ -214,34 +219,29 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
214
219
DEBUG_ERROR (" _crypto.readDeviceId(...) failed." );
215
220
return 0 ;
216
221
}
217
- #endif
222
+ #endif
218
223
219
- #ifdef BOARD_HAS_ECCX08
220
- if (!_crypto.begin ())
221
- {
222
- DEBUG_ERROR (" Cryptography processor failure. Make sure you have a compatible board." );
223
- return 0 ;
224
- }
225
- if (!_crypto.readDeviceId (getDeviceId (), CryptoSlot::DeviceId))
226
- {
227
- DEBUG_ERROR (" Cryptography processor read failure." );
228
- return 0 ;
229
- }
224
+ #if defined(BOARD_HAS_ECCX08) || defined(BOARD_HAS_SE050)
230
225
if (!_crypto.readCert (_cert, CryptoSlot::CompressedCertificate))
231
226
{
232
227
DEBUG_ERROR (" Cryptography certificate reconstruction failure." );
233
228
return 0 ;
234
229
}
235
- _sslClient.setClient (_connection->getClient ());
236
230
_sslClient.setEccSlot (static_cast <int >(CryptoSlot::Key), _cert.bytes (), _cert.length ());
237
- #elif defined(BOARD_ESP)
231
+ #endif
232
+
233
+ #if defined(BOARD_HAS_ECCX08)
234
+ _sslClient.setClient (_connection->getClient ());
235
+ #elif defined(BOARD_HAS_SE050)
236
+ _sslClient.appendCustomCACert (AIoTSSCert);
237
+ #elif defined(BOARD_ESP)
238
238
_sslClient.setInsecure ();
239
- #endif
239
+ #endif
240
240
241
241
_mqttClient.setClient (_sslClient);
242
- #ifdef BOARD_ESP
242
+ #ifdef BOARD_ESP
243
243
_mqttClient.setUsernamePassword (getDeviceId (), _password);
244
- #endif
244
+ #endif
245
245
_mqttClient.onMessage (ArduinoIoTCloudTCP::onMessage);
246
246
_mqttClient.setKeepAliveInterval (30 * 1000 );
247
247
_mqttClient.setConnectionTimeout (1500 );
0 commit comments