Skip to content

Commit 25bcfa3

Browse files
committed
Add notice about HTTPS security profile not being set up
1 parent 35e7bd9 commit 25bcfa3

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,15 @@
3939

4040
* Fixes a bug where the CELL LED wouldn't blink while the device was connecting to the network
4141
* Fixes a bug in the sandbox where some event flags could be cleared before being processed
42+
43+
# 1.1.4
44+
45+
## Features
46+
47+
* Split HTTP example into a HTTP and HTTPS example
48+
* Add a log message when HTTPS security profile is not set up
49+
50+
## Bugfixes
51+
52+
* Fix a bug where HTTP requests would make the modem hang
53+
* Fix a bug where retrieving the modem clock would fail

examples/https/https.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ void setup() {
2828

2929
if (!HttpClient.configure(DOMAIN, 443, true)) {
3030
Log.info("Failed to configure https client\r\n");
31+
return;
3132
}
3233

3334
Log.info("Configured to HTTPS");

src/http_client.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
// This results in 36 + 127 + 5 + 1 + 1 = 170
2121
#define HTTP_CONFIGURE_SIZE 170
2222

23+
#define QUERY_SECURITY_PROFILE "AT+SQNSPCFG"
24+
25+
#define SECURITY_PROFILE_PREFIX_LENGTH 11
26+
#define HTTPS_SECURITY_PROFILE_NUMBER '3'
27+
2328
#define HTTP_SEND "AT+SQNHTTPSND=0,%u,\"%s\",%lu"
2429
#define HTTP_RECEIVE "AT+SQNHTTPRCV=0,%lu"
2530
#define HTTP_QUERY "AT+SQNHTTPQRY=0,%u,\"%s\""
@@ -235,6 +240,49 @@ bool HttpClientClass::configure(const char *host,
235240

236241
SequansController.clearReceiveBuffer();
237242

243+
if (enable_tls) {
244+
245+
SequansController.writeCommand(QUERY_SECURITY_PROFILE);
246+
247+
char response[128] = "";
248+
249+
ResponseResult result =
250+
SequansController.readResponse(response, sizeof(response));
251+
252+
if (result != ResponseResult::OK) {
253+
Log.error("Failed to query HTTPS security profile");
254+
return false;
255+
}
256+
257+
// Split by line feed and carriage return to retrieve each entry
258+
char *ptr = strtok(response, "\r\n");
259+
bool security_profile_found = false;
260+
261+
while (ptr != NULL) {
262+
263+
// Skip the prefix of '+SQNSPCFG: '
264+
ptr += SECURITY_PROFILE_PREFIX_LENGTH;
265+
266+
// Now we check if the entry has the third security profile
267+
if (*ptr == HTTPS_SECURITY_PROFILE_NUMBER) {
268+
security_profile_found = true;
269+
break;
270+
}
271+
272+
ptr = strtok(NULL, "\r\n");
273+
}
274+
275+
if (!security_profile_found) {
276+
Log.error(
277+
"Security profile not set up for HTTPS. Run the "
278+
"'https_configure_ca' Arduino sketch example to set this up so "
279+
"that HTTPS can be used. More information here: "
280+
"https://iot.microchip.com/docs/arduino/userguide/http");
281+
282+
return false;
283+
}
284+
}
285+
238286
char command[HTTP_CONFIGURE_SIZE] = "";
239287
sprintf(command, HTTP_CONFIGURE, host, port, enable_tls ? 1 : 0);
240288

0 commit comments

Comments
 (0)