@@ -1068,33 +1068,30 @@ void azureIoTHubMqttProvision() {
10681068
10691069 SerialModule.println (" \r\n " );
10701070
1071- // Force a scope here to make sure the CA buffer is popped from the stack
1072- {
1073- switch (ca_type) {
1074- case DIGI_CERT_GLOBAL_ROOT_G2:
1075- strncpy_P (data_buffer,
1076- digi_cert_global_root_g2,
1077- sizeof (digi_cert_global_root_g2));
1078- break ;
1079- case BALTIMORE_CYBER_TRUST:
1080- strncpy_P (data_buffer,
1081- baltimore_cyber_trust,
1082- sizeof (baltimore_cyber_trust));
1083- break ;
1071+ switch (ca_type) {
1072+ case DIGI_CERT_GLOBAL_ROOT_G2:
1073+ strncpy_P (data_buffer,
1074+ digi_cert_global_root_g2,
1075+ sizeof (digi_cert_global_root_g2));
1076+ break ;
1077+ case BALTIMORE_CYBER_TRUST:
1078+ strncpy_P (data_buffer,
1079+ baltimore_cyber_trust,
1080+ sizeof (baltimore_cyber_trust));
1081+ break ;
10841082
1085- default :
1086- break ;
1087- }
1083+ default :
1084+ break ;
1085+ }
10881086
1089- ResponseResult result = writeCertificate (MQTT_CUSTOM_CA_SLOT,
1090- data_buffer);
1087+ const ResponseResult certificate_write_result =
1088+ writeCertificate (MQTT_CUSTOM_CA_SLOT, data_buffer);
10911089
1092- if (result != ResponseResult::OK) {
1093- SerialModule.printf (F (" Error occurred whilst storing CA "
1094- " certificate, error code: %X." ),
1095- static_cast <uint8_t >(result));
1096- return ;
1097- }
1090+ if (certificate_write_result != ResponseResult::OK) {
1091+ SerialModule.printf (F (" Error occurred whilst storing CA "
1092+ " certificate, error code: %X." ),
1093+ static_cast <uint8_t >(certificate_write_result));
1094+ return ;
10981095 }
10991096
11001097 // ------------------------------------------------------------------------
@@ -1174,19 +1171,34 @@ void azureIoTHubMqttProvision() {
11741171 // Step 3: Writing security profile
11751172 // ------------------------------------------------------------------------
11761173
1177- // We use TLS 1.2 for Azure IoT Hub and automatically detect ciphers.
1174+ // We use TLS 1.2 for Azure IoT Hub and the recommended ciphers:
1175+ //
1176+ // - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: 0xC02F
1177+ // - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: 0xC030
1178+ // - TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: 0xC027
1179+ // - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384: 0xC028
11781180 snprintf_P (command_buffer,
11791181 sizeof (command_buffer),
1180- AT_MQTT_SECURITY_PROFILE_WITH_CERTIFICATES ,
1182+ AT_MQTT_SECURITY_PROFILE_WITH_CERTIFICATES_ECC ,
11811183 2 ,
1182- " " ,
1184+ " 0xC02F;0xC030;0xC027;0xC028 " ,
11831185 1 ,
11841186 MQTT_CUSTOM_CA_SLOT,
11851187 MQTT_PUBLIC_KEY_SLOT,
11861188 MQTT_PRIVATE_KEY_SLOT,
11871189 " " ,
11881190 " " );
11891191
1192+ SequansController.writeBytes ((uint8_t *)command_buffer,
1193+ strlen (command_buffer),
1194+ true );
1195+
1196+ // Wait for URC confirming the security profile
1197+ if (!SequansController.waitForURC (" SQNSPCFG" , NULL , 0 , 4000 )) {
1198+ SerialModule.println (F (" Error whilst writing the security profile" ));
1199+ return ;
1200+ }
1201+
11901202 // ------------------------------------------------------------------------
11911203 // Step 4: Write device certificate to modem
11921204 // ------------------------------------------------------------------------
0 commit comments