From 75bf8c5bdde44dc55b3b6aa729e7f5da49055e28 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Tue, 7 Jul 2020 12:01:51 +0200 Subject: [PATCH] Bugfix: 'updateTimestampOnLocallyChangedProperties' was called before a connection had been established which led to the time service having a wrong date configured (1/1/2000) which leads to an expired certificate which inhibits the establishment of a connection to the server since the certificate has expired. This was triggered when properties where changed within 'setup' --- src/ArduinoIoTCloudTCP.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ArduinoIoTCloudTCP.cpp b/src/ArduinoIoTCloudTCP.cpp index 7cfe52d9b..31157bcc7 100644 --- a/src/ArduinoIoTCloudTCP.cpp +++ b/src/ArduinoIoTCloudTCP.cpp @@ -164,12 +164,18 @@ void ArduinoIoTCloudTCP::update() _ota_error = static_cast(err); #endif /* OTA_ENABLED */ - // Check if a primitive property wrapper is locally changed - updateTimestampOnLocallyChangedProperties(_property_container); - if(checkPhyConnection() != NetworkConnectionState::CONNECTED) return; if(checkCloudConnection() != ArduinoIoTConnectionStatus::CONNECTED) return; + /* Check if a primitive property wrapper is locally changed. + * This function requires an existing time service which in + * turn requires an established connection. Not having that + * leads to a wrong time set in the time service which inhibits + * the connection from being established due to a wrong data + * in the reconstructed certificate. + */ + updateTimestampOnLocallyChangedProperties(_property_container); + if(_mqtt_data_request_retransmit && (_mqtt_data_len > 0)) { write(_dataTopicOut, _mqtt_data_buf, _mqtt_data_len); _mqtt_data_request_retransmit = false;