Quectel GSM HTTPS Application Note V3.3
Quectel GSM HTTPS Application Note V3.3
Quectel GSM HTTPS Application Note V3.3
Application Note
Rev. GSM_HTTPS_Application_Note_V3.3
Date: 2020-01-13
Status: Released
www.quectel.com
GSM/GPRS Module Series
GSM HTTPS Application Note
Our aim is to provide customers with timely and comprehensive service. For any
assistance, please contact our company headquarters:
GENERAL NOTES
QUECTEL OFFERS THE INFORMATION AS A SERVICE TO ITS CUSTOMERS. THE INFORMATION
PROVIDED IS BASED UPON CUSTOMERS’ REQUIREMENTS. QUECTEL MAKES EVERY EFFORT
TO ENSURE THE QUALITY OF THE INFORMATION IT MAKES AVAILABLE. QUECTEL DOES NOT
MAKE ANY WARRANTY AS TO THE INFORMATION CONTAINED HEREIN, AND DOES NOT ACCEPT
ANY LIABILITY FOR ANY INJURY, LOSS OR DAMAGE OF ANY KIND INCURRED BY USE OF OR
RELIANCE UPON THE INFORMATION. ALL INFORMATION SUPPLIED HEREIN IS SUBJECT TO
CHANGE WITHOUT PRIOR NOTICE.
COPYRIGHT
THE INFORMATION CONTAINED HERE IS PROPRIETARY TECHNICAL INFORMATION OF
QUECTEL WIRELESS SOLUTIONS CO., LTD. TRANSMITTING, REPRODUCTION, DISSEMINATION
AND EDITING OF THIS DOCUMENT AS WELL AS UTILIZATION OF THE CONTENT ARE
FORBIDDEN WITHOUT PERMISSION. OFFENDERS WILL BE HELD LIABLE FOR PAYMENT OF
DAMAGES. ALL RIGHTS ARE RESERVED IN THE EVENT OF A PATENT GRANT OR
REGISTRATION OF A UTILITY MODEL OR DESIGN.
Copyright © Quectel Wireless Solutions Co., Ltd. 2020. All rights reserved.
GSM_HTTPS_Application_Note 1 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
History
GSM_HTTPS_Application_Note 2 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
Contents
1 Introduction ......................................................................................................................................... 5
1.1. SSL Version and Cipher Suite ................................................................................................... 5
1.2. The Procedure of Using SSL Function ...................................................................................... 6
1.3. Error Handling ............................................................................................................................ 6
1.3.1. PDP Activation Fails ........................................................................................................ 6
3 Example ............................................................................................................................................. 17
3.1. SSL Function with Certificate and Key in RAM ....................................................................... 17
3.2. SSL Function with Certificate and key in NVRAM ................................................................... 18
3.3. Example about SSL Function with HTTPS .............................................................................. 18
3.3.1. Send HTTP GET Response .......................................................................................... 18
3.3.2. Send HTTP POST Request .......................................................................................... 20
4 Appendix A References.................................................................................................................... 22
GSM_HTTPS_Application_Note 3 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
Table Index
GSM_HTTPS_Application_Note 4 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
1 Introduction
This document mainly introduces how to use the HTTPS function of Quectel GSM modules. HTTPS is
used to secure the data transmission.
Hypertext Transfer Protocol Secure (HTTPS) is a combination of the Hypertext Transfer Protocol (HTTP)
with SSL/TLS protocols to provide encrypted communication and secure identification of a network web
server. HTTPS is the result of simply layering the HTTP on the top of the SSL/TLS protocols, thus adding
the security capabilities of SSL/TLS to standard HTTP communication.
In some cases, in order to ensure communication privacy, the communication between the server and the
client should be in an encrypted way, and SSL function can prevent data from being eavesdropped,
tampered, or forged during the communication process.
The following SSL versions are supported by Quectel GSM modules currently.
SSL3.0
TLS1.0
TLS1.1
TLS1.2
The following table shows the SSL cipher suites supported by Quectel GSM modules. For detailed
description of cipher suites, please refer to RFC 2246-The TLS Protocol Version 1.0.
GSM_HTTPS_Application_Note 5 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
0X0035 TLS_RSA_WITH_AES_256_CBC_SHA
0X0005 TLS_RSA_WITH_RC4_128_SHA
0X0004 TLS_RSA_WITH_RC4_128_MD5
0X000A TLS_RSA_WITH_3DES_EDE_CBC_SHA
0X002F TLS_RSA_WITH_AES_128_CBC_SHA
0X003D TLS_RSA_WITH_AES_256_CBC_SHA256
Step 1: Install certificate and key to RAM or NVRAM by AT+QSECWRITE command. AT+QSECDEL is
used to delete the certificate and key, and AT+QSECREAD is used to check the checksum of
certificate and key. If the server and client authentication is not needed, please skip this step.
Step 2: Configure the APN, username, password of context by AT+QICSGP command. AT+QIREGAPP
is used to register on TCP/IP stack.
Step 3: Activate GPRS PDP context by AT+QIACT command. After the PDP context has been activated,
please query the local IP address by AT+QILOCIP command.
Step 4: Configure SSL version, cipher suit, server authentication, client authentication, server root CA
certificate, client certificate and client key by AT+QSSLCFG command.
Step 5: Configure URL by AT+QHTTPURL command. After CONNECT is returned, enter URL in the
format of: "https:URL".
Step 6: Send HTTP GET request by AT+QHTTPGET command.
Step 7: Read HTTP server response by AT+QHTTPREAD command.
If PDP context is failed to be activated by AT+QIACT command, please check the following
configurations:
1. Query whether the PS domain is attached by AT+CGATT? command. If not, execute AT+CGATT=1
command to attach PS domain.
GSM_HTTPS_Application_Note 6 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
2. Query AT+CGREG status by AT+CGREG? command and make sure the PS domain is registered.
3. Query the PDP context parameters by AT+QIREGAPP command and make sure the APN of
specified PDP context is set.
4. Make sure the specified PDP context ID is neither used by PPP nor activated by AT+CGACT
command.
5. The module only supports two PDP contexts activated simultaneously, so please make sure the
amount of activated PDP context is no more than 2.
If all above configurations are confirmed, but the result of executing command AT+QIACT always fails,
please reboot the module to resolve this issue. After rebooting the module, please check the
configurations mentioned above at least three times at an interval of 10 minutes to avoid frequent
rebooting of the module.
GSM_HTTPS_Application_Note 7 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
2 Description of AT Commands
NOTES
1. <…>: Parameter name. Angle brackets do not appear on the command line. The parameter value
indicated by "_" is the default one.
2. […]: Optional parameter. Square brackets do not appear on the command line. When an optional
parameter is omitted, the default value will be used unless otherwise specified.
This AT command is used to configure the SSL version, cipher suite, secure level, server root CA
certificate, client certificate, client key, RTC time ignorance and SSL context index of HTTP/HTTPS.
These parameters will be used in the handshake procedure.
CTX is the abbreviation of SSL context. <CTX_index> is the index of the SSL context. Quectel GSM
modules support six SSL contexts at most. And on the basis of an SSL context, several SSL connections
GSM_HTTPS_Application_Note 8 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
can be established. The settings such as SSL version and cipher suite are stored in the SSL context, and
they will be applied to a new SSL connection which is associated with the SSL context.
OK
Read Command Response
Query settings of the context +QSSLCFG: <CTX_index>,<SSL_version>,<seclevel>,<c
AT+QSSLCFG="ctxindex",<CTX_inde ipher_suite>,<cacert>,<client_cert_name>,<client_key_n
x> ame>
OK
Or
ERROR
Write Command Response
Configure SSL version If <SSL_version> is omitted, query the SSL version:
AT+QSSLCFG="sslversion",<CTX_in +QSSLCFG: "sslversion",<SSL_version>
dex>[,<SSL_version>]
OK
GSM_HTTPS_Application_Note 9 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
OK
OK
GSM_HTTPS_Application_Note 10 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
OK
OK
Parameter
GSM_HTTPS_Application_Note 11 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
0X0035 TLS_RSA_WITH_AES_256_CBC_SHA
0X002F TLS_RSA_WITH_AES_128_CBC_SHA
0X0005 TLS_RSA_WITH_RC4_128_SHA
0X0004 TLS_RSA_WITH_RC4_128_MD5
0X000A TLS_RSA_WITH_3DES_EDE_CBC_SHA
0X003D TLS_RSA_WITH_AES_256_CBC_SHA256
<seclevel> Integer type. Configure the authentication mode.
0 No authentication
1 Manage server authentication
2 Manage server and client authentication if requested by the remote
server
<CA_cert_name> String format. Configure the server root CA certificate.
<client_cert_name> String format. Configure the client certificate.
<client_key_name> String format. Configure the client key.
<ignore_RTC_time> Integer type. Configure whether to ignore the RTC time.
0 Do not ignore the RTC time
1 Ignore the RTC time
<HTTPS_enable> Integer type. Enable/disable the HTTPS function.
0 Disable HTTPS
1 Enable HTTPS
<HTTPS_CTX_index> Integer type. SSL context for HTTPS. It is the index of SSL context. Range: 0-5. If
the host does not configure it, the value is -1.
NOTES
This command is used to add user certificate, user key and server root CA certificate to RAM or NVRAM.
And the certificate and key will be stored in these storages in an encrypted way. After the certificate and
key are stored in these storages, the host cannot read the data from these storages and can only query
GSM_HTTPS_Application_Note 12 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
the checksum of them. Please note that the certificate or key should not exist in the corresponding
storage until it is added to RAM or NVRAM; if it already exists, the host should delete it first, and then add
it to the corresponding storage.
OK
Read Command Response
AT+QSECWRITE? OK
Or
ERROR
Write Command Response
AT+QSECWRITE=<file_name>,<file_s If format is correct, response:
ize> [,<timeout>] CONNECT
After the module switches to data mode, the certificate or key
data can be input. When the size of the input data reaches
<file_size> (unit: byte) or the module receives +++ sequence
from UART, the module will return to command mode and
reply the following codes:
+QSECWRITE: <upload_size>,<checksum>
OK
Parameter
<file_name> String format. The name of the file to be stored. The format can be as follows:
"RAM:filename" File is uploaded to RAM
"NVRAM:filename" File is uploaded to NVRAM. Support server root CA certificate,
one client certificate and one client private key. The filename of
server root CA certificate must be CA0, the filename of client
certificate must be CC0, and the filename of client private key
must be CK0.
CA0 Identify a server root CA certificate
CC0 Identify a client certificate
CK0 Identify a client private key
<file_size> The size of the file to be uploaded. Unit: byte.
GSM_HTTPS_Application_Note 13 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
If the file is uploaded to the RAM, the maximum size is 32768. If the file is uploaded to
NVRAM, the maximum size is 2017 and the minimum size is 1.
<timeout> The time in seconds to wait for data input via UART port. Unit: byte. Range: 3-200. The
default value is 100.
<upload_size> The size of the actual uploaded data. Unit: byte.
<checksum> The checksum of the uploaded data.
NOTE
When the file is uploaded to RAM, the configuration will not be saved. When the file is uploaded to
NVRAM, the configuration will be saved automatically.
This command is used to query the checksum of a certificate or key. If the checksum is not the same as
the original one owned by the user, some mistakes will occur.
OK
Read Command Response
AT+QSECREAD? OK
Or
ERROR
Write Command Response
AT+QSECREAD=<file_name> +QSECREAD: <good>,<checksum>
OK
Characteristics /
Parameter
<file_name> String format. The name of the file to be stored. The format can be as follows:
"RAM:filename" Query the checksum of file that is stored in RAM.
"NVRAM:filename" Query the checksum of file that is stored in NVRAM. Support
server root CA certificate, one client certificate and one client
private key. The filename of server root CA certificate must be
GSM_HTTPS_Application_Note 14 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
OK
Read Command Response
AT+QSECDEL? OK
Or
ERROR
Write Command Response
AT+QSECDEL=<file_name> OK
Characteristics /
Parameter
<file_name> The name of the file to be stored. The format can be as follows:
"RAM:filename" Delete a certificate or key that is stored in RAM
"NVRAM:filename" Delete a certificate or key that is stored in NVRAM. Support
server root CA certificate, one client certificate and one client
private key. The filename of server root CA certificate must be
CA0, the filename of client certificate must be CC0, and the
GSM_HTTPS_Application_Note 15 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
GSM_HTTPS_Application_Note 16 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
3 Example
This is an example about how to set server and client authentication, and the certificate and key are
stored in RAM. If the server and client authentication are not needed, please skip this step.
+QSECWRITE: 1614,4039
OK
AT+QSECWRITE="RAM:client_cert.pem",1419,100 //Upload the client certificate to RAM.
CONNECT
+QSECWRITE: 1419,618
OK
AT+QSECWRITE="RAM:client_key.pem",1679,100 //Upload the client private key to RAM.
CONNECT
+QSECWRITE: 1679,83a7
OK
GSM_HTTPS_Application_Note 17 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
This is an example about how to set server and client authentication, and the certificate and key are
stored in NVRAM. If the server and client authentication are not needed, please skip this step.
+QSECWRITE: 1614,4039
OK
AT+QSECWRITE="NVRAM:CC0",1419,100 //Upload the client certificate to NVRAM.
CONNECT
+QSECWRITE: 1419,618
OK
+QSECWRITE: 1679,83a7
OK
GSM_HTTPS_Application_Note 18 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
OK
AT+QIACT //Activate GPRS PDP context.
OK
AT+QILOCIP //Query the local IP address.
10.1.83.188
//Step 3: Enable HTTPS function and configure SSL context index for HTTPS.
GSM_HTTPS_Application_Note 19 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
//Step 3: Enable HTTPS function and configure SSL context index for HTTPS.
AT+QSSLCFG="https",1 //Enable HTTPS function.
OK
AT+QSSLCFG="httpsctxi",2 //Configure SSL context index as 2.
OK
AT+QHTTPURL=45,60 //Set the URL.
CONNECT
……….
//For example, input 45 bytes: https://220.180.239.212:8011/processorder.php.
OK
AT+QHTTPPOST=48,60,60 //Send POST data.
CONNECT
……….
GSM_HTTPS_Application_Note 20 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
GSM_HTTPS_Application_Note 21 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
4 Appendix A References
Abbreviation Description
ID Identification
IP Internet Protocol
ME Mobile Equipment
GSM_HTTPS_Application_Note 22 / 23
GSM/GPRS Module Series
GSM HTTPS Application Note
GSM_HTTPS_Application_Note 23 / 23