2828 #include " tls/utility/CryptoUtil.h"
2929#endif
3030
31+ #ifdef BOARD_HAS_SE050
32+ #include " tls/AIoTCSSCert.h"
33+ #include " tls/utility/CryptoUtil.h"
34+ #endif
35+
3136#ifdef BOARD_HAS_OFFLOADED_ECCX08
3237#include < ArduinoECCX08.h>
3338#include " tls/utility/CryptoUtil.h"
@@ -203,7 +208,7 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
203208 _ota_img_sha256 = sha256_str;
204209#endif /* OTA_ENABLED */
205210
206- # ifdef BOARD_HAS_OFFLOADED_ECCX08
211+ # if defined(BOARD_HAS_ECCX08) || defined( BOARD_HAS_OFFLOADED_ECCX08) || defined(BOARD_HAS_SE050)
207212 if (!_crypto.begin ())
208213 {
209214 DEBUG_ERROR (" _crypto.begin() failed." );
@@ -214,34 +219,29 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
214219 DEBUG_ERROR (" _crypto.readDeviceId(...) failed." );
215220 return 0 ;
216221 }
217- #endif
222+ #endif
218223
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)
230225 if (!_crypto.readCert (_cert, CryptoSlot::CompressedCertificate))
231226 {
232227 DEBUG_ERROR (" Cryptography certificate reconstruction failure." );
233228 return 0 ;
234229 }
235- _sslClient.setClient (_connection->getClient ());
236230 _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)
238238 _sslClient.setInsecure ();
239- #endif
239+ #endif
240240
241241 _mqttClient.setClient (_sslClient);
242- #ifdef BOARD_ESP
242+ #ifdef BOARD_ESP
243243 _mqttClient.setUsernamePassword (getDeviceId (), _password);
244- #endif
244+ #endif
245245 _mqttClient.onMessage (ArduinoIoTCloudTCP::onMessage);
246246 _mqttClient.setKeepAliveInterval (30 * 1000 );
247247 _mqttClient.setConnectionTimeout (1500 );
0 commit comments