Quectel GSM SSL Application Note V3.3
Quectel GSM SSL Application Note V3.3
Quectel GSM SSL Application Note V3.3
Application Note
Rev. GSM_SSL_Application_Note_V3.3
Date: 2020-04-01
Status: Released
www.quectel.com
GSM/GPRS/GNSS Module Series
GSM SSL 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_SSL_Application_Note 1 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
Revision History
GSM_SSL_Application_Note 2 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
Contents
1 Introduction .......................................................................................................................................... 5
1.1. SSL Version and Cipher Suite ..................................................................................................... 5
1.2. The Process of Using SSL Function ............................................................................................ 6
1.3. SSL Function Coexists with Normal TCP/IP Session .................................................................. 6
3 Examples ............................................................................................................................................ 24
3.1. SSL Function with Certificate and Key in RAM ......................................................................... 24
3.2. SSL Function with Certificate and Key in NVRAM .................................................................... 26
3.3. Example about SSL Function Coexisting with Normal TCP/IP Function................................... 28
3.4. Example about Transparent Mode of SSL Function .................................................................. 30
3.4.1. No Authentication ............................................................................................................. 30
3.4.2. Server and Client Authentication...................................................................................... 32
5 Appendix A Reference....................................................................................................................... 36
GSM_SSL_Application_Note 3 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
Table Index
GSM_SSL_Application_Note 4 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
1 Introduction
This document describes how to use the SSL function of Quectel GSM modules.
In some cases, in order to ensure communication privacy, the communication between the server and the
client should be in an encrypted way so that data can be prevented from eavesdropping, tampering, or
forging during the communication process. The SSL function meets these demands.
SSL Version
SSL3.0
TLS1.0
TLS1.1
TLS1.2
The following table shows 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.
0X0035 TLS_RSA_WITH_AES_256_CBC_SHA
0X0005 TLS_RSA_WITH_RC4_128_SHA
GSM_SSL_Application_Note 5 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
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 file system by AT+QSECWRITE. AT+QSECDEL deletes the
certificate and key, and AT+QSECREAD checks the checksum of certificate and key.
Step 2: Configure APN, username and password of the context by AT+QIFGCNT and AT+QICSGP.
And start TCP/IP task by AT+QIREGAPP.
Step 3: Activate GPRS PDP context by AT+QIACT. After the context is activated, query the local IP
address by AT+QILOCIP.
Step 4: Configure SSL version, cipher suite, server authentication, client authentication, server root CA
certificate, client certificate and client key by AT+QSSLCFG.
Step 5: Establish an SSL connection by AT+QSSLOPEN. If the connection is successful, the
response will be "CONNECT" or "+QSSLOPEN: <ssid>,<connectcode>".
Step 6: In non-transparent mode, data is sent by AT+QSSLSEND. If the module receives data from
network, it will report an URC: "+QSSLURC: "recv",<cid>,<ssid>", and can read the received
data by AT+QSSLRECV.
In transparent mode, data transmission and receiving are directly input and output from the serial
COM port. +++ or DTR can be used to exit from the data mode and enter command mode. If
the connection is abnormal, module will automatically exit from the data mode.
Step 7: When data transmission is accomplished, close the SSL connection by AT+QSSLCLOSE.
Step 8: Deactivate GPRS PDP context by AT+QIDEACT.
SSL connection can coexist with normal TCP connection, which means one or several SSL and normal
TCP connections can be established at the same time.
In the same foreground context, please establish SSL and normal TCP connections with different socket
indexes. For example, establish a normal TCP connection with socket index one, and establish an SSL
connection with socket index three.
The following steps show how SSL function works together with normal TCP session.
GSM_SSL_Application_Note 6 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
Step 1: Configure APN, username and password of the context by AT+QIFGCNT and AT+QICSGP.
Step 2: Enable multiple TCP/IP session by AT+QIMUX=1.
Step 3: Start TCP/IP task by AT+QIREGAPP.
Step 4: Activate GPRS PDP context by AT+QIACT. After the context is activated, query the local IP
address by AT+QILOCIP.
Step 5: Configure the method of handling received TCP/IP data with buffer mode by AT+QINDI=1.
Execute AT+QIOPEN to establish a normal TCP connection, and specify <index> as 1. After
the normal TCP connection is established successfully, data can be sent by AT+QISEND and
received by AT+QIRD. If It is necessary to close the connection, execute AT+QICLOSE.
Step 6: Establish an SSL connection by AT+QSSLOPEN, and specify <ssid> as 3. After the
connection is established successfully, send data by AT+QSSLSEND. When module
receives data from the peer, the URC "+QSSLURC: "recv",<cid>,<ssid>" will notify the host to
read data. And host can execute the AT+QSSLRECV to read data. When data transmission
is accomplished, close the SSL connection by AT+QSSLCLOSE.
Step 7: Deactivate GPRS PDP context by AT+QIDEACT.
NOTE
GSM_SSL_Application_Note 7 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
2.1.1. Definitions
The AT or at prefix must be added at the beginning of each command line. Entering <CR> will terminate a
command line. Commands are usually followed by a response that includes
<CR><LF><response><CR><LF>. Throughout this document, only the response <response> will be
presented, <CR><LF> are omitted intentionally.
GSM_SSL_Application_Note 8 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
The command configures the SSL version, cipher suites, security level, server root CA certificate, client
certificate, client key, whether to ignore RTC time, HTTP/HTTPS, and SMTP/SMTPS. These parameters
will be used in the handshake procedure.
CTX refers to the abbreviation of the SSL (Secure Socket Layer) context, and <ctxindex> is the index of
the SSL context. Quectel GSM module supports 6 SSL contexts at most. Several SSL connections can be
established on the basis of one SSL context. The settings such as the SSL version and the cipher suite
are stored in the SSL context, and will be applied to the new SSL connection associated with the SSL
context.
OK
Write Command Response
Query the setting of the context: +QSSLCFG: <ctxindex>,<sslversion>,<seclevel>,<cipher
AT+QSSLCFG="ctxindex",<ctxindex> suite>,<cacertname>,<clientcertname>,<clientkeyname>
OK
Or
ERROR
Write Command Response
Configure the SSL version for the If <sslversion> is omitted, query the SSL version for the
specified SSL context: specified SSL context:
AT+QSSLCFG="sslversion",<ctxinde +QSSLCFG: "sslversion",<sslversion>
x>[,<sslversion>]
OK
GSM_SSL_Application_Note 9 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
ex>[,<ciphersuite>]
OK
GSM_SSL_Application_Note 10 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
Write Command Response
Configure the path of client private key If <clientkeyname> is omitted, query the path of client private
for the specified SSL context: key for the specified SSL context:
AT+QSSLCFG="clientkey",<ctxindex +QSSLCFG: "clientkey",<clientkeyname>
>[,<clientkeyname>]
OK
OK
GSM_SSL_Application_Note 11 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
HTTPS:
OK
Or
ERROR
Write Command Response
Configure the type of SMTP/SMTPS: If <smtpstyle> is omitted, query the type of SMTP/SMTPS:
AT+QSSLCFG="smtpstyle"[,<smtpsty +QSSLCFG: "smtpstyle",<smtpstyle>
le>]
OK
Parameter
GSM_SSL_Application_Note 12 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
0X000A TLS_RSA_WITH_3DES_EDE_CBC_SHA
0X003D TLS_RSA_WITH_AES_256_CBC_SHA256
0XFFFF All
<seclevel> Numeric type. Authentication mode.
0 No authentication
1 Manage server authentication
2 Manage server and client authentication if requested by the remote
server
<cacertname> String type. The path of the trusted server root CA certificate.
<clientcertname> String type. The path of the client certificate.
<clientkeyname> String type. The path of the client private key.
<ignorertctime> Numeric type. Configure whether to ignore the RTC time.
0 Not ignore the RTC time
1 Ignore the RTC time
<httpsenable> Enable/disable the HTTPS function.
0 Disable HTTPS
1 Enable HTTPS
<httpsctxindex> SSL context for HTTPS.
The parameter is the index of SSL context. If the host does not configure it, its
value is -1. Range: 0–5.
<smtpstyle> Type of SMTP/SMTPS.
0 No SSL
1 SSL
2 STARTTLS
<smtpsctxindex> SSL context for SMTPS.
The parameter is the index of SSL context. If the host does not configure it, its
value is -1. Range: 0–5.
NOTES
GSM_SSL_Application_Note 13 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
The command opens an SSL socket to connect a remote server. During the negotiation between the
module and the peer, AT+QSSLCFG will be used for parameter configuration in handshake procedure.
After shaking hands with the peer successfully, the module can send or receive data via this SSL
connection. Also the module can establish several SSL connections based on one SSL context.
The host can configure a timeout for AT+QSSLOPEN. If module does not finish establishing an SSL
connection until timeout period has expired, the URC "+QSSLOPEN: <ssid>,<connectcode>" will be
reported. If the host does not configure timeout value, the default value of timeout is 90 seconds.
OK
Read Command Response
AT+QSSLOPEN? OK
Write Command Response
AT+QSSLOPEN=<ssid>,<ctxindex>,<i If <connectmode> is transparent mode and the SSL
paddr/domainname>,<port>,<connect connection is established successfully:
mode>[,<timeout>] CONNECT
Parameter
GSM_SSL_Application_Note 14 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
0 Not transparent mode
1 Transparent mode
<timeout> Timeout time. Range: 10–300. Default: 90. Unit: second.
<connectcode> The result of connection.
0 Success
-1 Error
-2 Socket is occupied
After the SSL connection is established, the module can send data through the connection. If sending
data successfully, the module will return SEND OK. If the process of sending data is blocked, the module
will return SEND FAIL. And if some other errors occur, the module will return ERROR.
When receiving SEND FAIL, the host should delay some time for sending data. When receiving ERROR,
the host should establish SSL connection again.
OK
Read Command Response
AT+QSSLSEND? OK
Write Command Response
AT+QSSLSEND=<ssid>[,<length>] >
After response >, input the data to be <input data>
sent. Tap CTRL+Z to send, and tap <CTRL+Z>
"ESC" to cancel the operation.
If SSL connection has been established and data sending is
successful:
SEND OK
GSM_SSL_Application_Note 15 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
Parameter
When module receives data from the peer host, it can read data from buffer. After receiving data, the
module will buffer it and report "+QSSLURC: "recv",<cid>,<ssid>" to notify the host. Then the peer host
can retrieve data by AT+QSSLRECV.
OK
Write Command Response
AT+QSSLRECV=<cid>,<ssid>,<length If data has been received through specified connection:
> +QSSLRECV: <ipaddr>:<port>,TCP,<actual length><CR>
<LF><data>
OK
Parameter
GSM_SSL_Application_Note 16 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
NOTE
If the buffer is not empty, and the module receives data again, then it will not report URC "+QSSLURC:
"recv",<cid>,<ssid>" until all the received data has been retrieved by AT+QSSLRECV from buffer.
The command closes an SSL connection. If all the SSL connections based on the same SSL context are
closed, the module will release the SSL context.
OK
Read Command Response
AT+QSSLCLOSE? OK
Write Command Response
AT+QSSLCLOSE=<ssid> If the SSL connection is closed successfully:
CLOSE OK
Parameter
This command queries the socket connection status. It can not only query the status of SSL connection,
but also the status of the normal TCP/UDP connection.
GSM_SSL_Application_Note 17 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
Write Command Response
AT+QSSLSTATE If the socket connection status is queried successfully:
+QSSLSTATE: <state>
+QSSLSTATE: <socketindex>,<connectiontype>,<ipadd
r>,<port>,<socketstatus>,<sslconnectionflag>
…
OK
Parameter
GSM_SSL_Application_Note 18 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
The command adds a user certificate, user key or 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 is
stored in these storages, the host cannot read the data from these storages and can only query the data
checksum. 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 and then add it to the
corresponding storage.
OK
Read Command Response
AT+QSECWRITE? OK
Write Command Response
AT+QSECWRITE=<filename>,<filesiz If the AT command format is right:
e> [,<timeout>] CONNECT
After module switches to data mode, the certificate or key
data can be inputted. When the size of the inputted data
reaches <filesize> (unit: byte) or module receives +++
sequence from UART, the module will return to command
mode and reply the following codes.
+QSECWRITE: <uploadsize>,<checksum>
OK
Parameter
<filename> 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
GSM_SSL_Application_Note 19 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
must be CK0.
CA0 Identify a server root CA certificate
CC0 Identify a client certificate
CK0 Identify a client key
<filesize> The size of the file to be uploaded. Unit: byte.
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. The minimum size is 1.
<timeout> The time in seconds to wait for inputted data from UART.
Range: 3–200. Default: 100. Unit: second.
<uploadsize> The size of the actual uploaded data. Unit: byte.
<checksum> The checksum of the uploaded data.
The command queries the checksum of a certificate or key. If the checksum is not the same as the
original one which is owned by the user, some mistakes will occur.
OK
Write Command Response
AT+QSECREAD=<filename> +QSECREAD: <good>,<checksum>
OK
If there is any error:
+CME ERROR: <err>>
The command takes effect immediately.
Characteristics
The configurations will not be saved.
Parameter
<filename> 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 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
GSM_SSL_Application_Note 20 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
CK0 Identify a client key
<good> Indicate the certificate or key is correct or not. When uploading the certificate or key by
AT+QSECWRITE, the checksum of certificate or key will be stored at the same time.
After executing AT+QSECREAD, checksum of the certificate or key will be calculated
again. Then compare this checksum with the one stored by AT+QSECWRITE. If they are
the same, the certificate or key is correct, otherwise it is wrong.
0 The certificate or key is wrong
1 The certificate or key is correct
<checksum> The checksum of the file.
OK
Write Command Response
AT+QSECDEL=<filename> OK
Parameter
<filename> 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. Server root CA
certificate, one client certificate and one client private key are
supported. 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 key
GSM_SSL_Application_Note 21 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
The format of SSL URC is "+QSSLURC:" and it is mainly used to notify the host to read received data
and disconnect the connections.
+QSSLURC: "recv",<cid>,<ssid> This is a URC to notify the host to read SSL data.
Parameter
NOTES
1. Module has a socket buffer which stores the received data. When module receives the data from the
peer, it will put the data into the socket buffer. Only in the case that the socket buffer is empty, and the
data from the peer arrivals, then module will report the URC "+QSSLURC: "recv",<cid>,<ssid>" to
notify host to read. Host can use AT+QSSLRECV to read the data. When the socket buffer is not
empty, and the data arrivals, then module will not report the URC.
2. AT+QSSLRECV=<cid>,<ssid>,<length> reads the data from the module's socket buffer. The
maximum length to be read is 1500. If the data length in the buffer is less than 1500, this command
will read all the data.
The URC notifies host that the connection has been disconnected. The disconnection can be caused by a
number of reasons such as peer closing the connection or GPRS PDP being deactivated. If this URC is
reported, the module will close SSL connection automatically, and the host does not need to execute
AT+QSSLCLOSE to close the SSL connection.
Notify Disconnection
+QSSLURC: "closed",<ssid> The SSL connection based on the specified socket is closed.
GSM_SSL_Application_Note 22 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
Parameter
GSM_SSL_Application_Note 23 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
3 Examples
This is an example about server authentication and client authentication, and the certificate and key are
stored in RAM. It shows how to establish SSL connection and implement data sending and receiving
between module and server.
OK
AT+QSECWRITE="RAM:client_cert.pem",1419,100 //Upload the client certificate to RAM.
CONNECT
<Input the client_cert.pem data, the size is 1419 bytes>
+QSECWRITE: 1419,618
OK
AT+QSECWRITE="RAM:client_key.pem",1679,100 //Upload the client private key to RAM.
CONNECT
<Input the client_key.pem data, the size is 1679 bytes>
+QSECWRITE: 1679,83a7
OK
GSM_SSL_Application_Note 24 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
AT+QIACT //Activate GPRS PDP context.
OK
AT+QILOCIP //Query local IP address.
10.1.83.188
//Step 3: Configure SSL version, cipher suite, server authentication and client authentication. And
certificate and private key are in RAM.
AT+QSSLCFG="ignorertctime",1 //Ignore the RTC time.
OK
AT+QSSLCFG="sslversion",0,4 //Configure SSL version.
OK
AT+QSSLCFG="ciphersuite",0,"0XFFFF" //Configure cipher suite.
OK
AT+QSSLCFG="seclevel",0,2 //Configure Server authentication and client
authentication.
OK
AT+QSECREAD="RAM:ca_cert.pem" //Check CA certificate is correct or not.
+QSECREAD: 1,4039
OK
AT+QSECREAD="RAM:client_cert.pem" //Check client certificate is correct or not.
+QSECREAD: 1,618
OK
AT+QSECREAD="RAM:client_key.pem" //Check client private key is correct or not.
+QSECREAD: 1,83a7
OK
AT+QSSLCFG="cacert",0,"RAM:ca_cert.pem" //Configure CA certificate.
OK
AT+QSSLCFG="clientcert",0,"RAM:client_cert.pem" //Configure client certificate.
OK
AT+QSSLCFG="clientkey",0,"RAM:client_key.pem" //Configure client key.
OK
GSM_SSL_Application_Note 25 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
AT+QSSLSEND=1 //Send data in any byte less than 1460.
> <input some bytes data>,<Ctrl+Z> //After completing data input, tap CTRL+Z to send.
SEND OK
+QSSLURC: "recv",0,1 //Notify the host to acquire the data from the server.
AT+QSSLRECV=0,1,1500 //Read data and output the data to UART.
+QSSLRECV: 116.247.104.27:465,TCP,7
1234567
OK
//Step 5: Close SSL connection, delete the certificate and key from RAM.
AT+QSSLCLOSE=1 //Close socket index 1.
CLOSE OK
AT+QSECDEL="RAM:ca_cert.pem"
OK
AT+QSECDEL="RAM:client_cert.pem"
OK
AT+QSECDEL="RAM:client_key.pem"
OK
AT+QIDEACT //Deactivate GPRS PDP context.
DEACT OK
This is an example about server authentication and client authentication, and the certificate and key are
stored in NVRAM. It shows how to establish SSL connection, implement data sending and receiving
between module and server.
OK
AT+QSECWRITE="NVRAM:CC0",1419,100 //Upload the client certificate to NVRAM.
CONNECT
<Input the CC0 data, the size is 1419 bytes>
+QSECWRITE: 1419,618
OK
GSM_SSL_Application_Note 26 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
AT+QSECWRITE="NVRAM:CK0",1679,100 //Upload the client private key to NVRAM.
CONNECT
<Input the CK0 data, the size is 1679 bytes>
+QSECWRITE: 1679,83a7
OK
//Step 3: Configure SSL version, cipher suite, server authentication and client authentication. Certificate
and private key are in NVRAM.
AT+QSSLCFG="ignorertctime",1 //Ignore the RTC time.
OK
AT+QSSLCFG="sslversion",0,4 //Configure SSL version.
OK
AT+QSSLCFG="ciphersuite",0,"0XFFFF" //Configure cipher suite.
OK
AT+QSSLCFG="seclevel",0,2 //Configure server authentication and client
authentication.
OK
AT+QSECREAD="NVRAM:CA0" //Check server root CA certificate is correct or not.
+QSECREAD: 1,4039
OK
AT+QSECREAD="NVRAM:CC0" //Check client certificate is correct or not.
+QSECREAD: 1,618
OK
AT+QSECREAD="NVRAM:CK0" //Check client private key is correct or not.
+QSECREAD: 1,83a7
OK
GSM_SSL_Application_Note 27 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
AT+QSSLCFG="cacert",0,"NVRAM:CA0" //Configure server root CA certificate.
OK
AT+QSSLCFG="clientcert",0,"NVRAM:CC0" //Configure client certificate.
OK
AT+QSSLCFG="clientkey",0, "NVRAM:CK0" //Configure client key.
OK
+QSSLURC: "recv",0,1 //Notify the host to acquire the data from the server.
AT+QSSLRECV=0,1,1500 //Read data and output the data to UART.
+QSSLRECV: 116.247.104.27:465,TCP,7
1234567
OK
Function
GSM_SSL_Application_Note 28 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
AT+QICSGP=1,"CMNET" //Set bear type as GPRS and APN as
"CMNET", which does not have a username and password.
AT+QIMUX=1 //Enable multiple TCP/IP session.
OK
AT+QIREGAPP //Register to TCP/IP stack.
OK
AT+QIACT //Activate GPRS PDP context.
OK
AT+QILOCIP //Query local IP address.
10.1.83.188
//Step 3: Configure SSL version, cipher suite and no authentication mode. Establish SSL connection, send
and receive data.
AT+QSSLCFG="sslversion",0,4 //Configure SSL version.
OK
AT+QSSLCFG="seclevel",0,0 //Configure Server authentication and client
authentication.
OK
AT+QSSLCFG="ciphersuite",0,"0XFFFF" //Configure cipher suite.
OK
AT+QSSLOPEN=3,0,"124.74.41.170",5115,0 //Establish SSL connection and the socket index is 3,
GSM_SSL_Application_Note 29 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
and the connection is based on context 0.
OK
> <Input some bytes data>,<Ctrl+Z> //After completing to input data, tap CTRL+Z to send
data.
SEND OK
+QSSLURC: "recv",0,3 //URC, notify the host to acquire the data from the
server.
AT+QSSLRECV=0,3,1000 //Read the data and output the data to UART.
+QSSLRECV: 124.74.41.170:5115,TCP,7
1234567
OK
3.4.1. No Authentication
GSM_SSL_Application_Note 30 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
AT+QIACT //Activate GPRS PDP context.
OK
AT+QILOCIP //Query local IP address.
10.1.83.188
//Step 2: Configure SSL version, cipher suite and no authentication mode. Establish SSL connection, send
and receive data.
AT+QSSLCFG="sslversion",0,4 //Configure SSL version.
OK
AT+QSSLCFG="seclevel",0,0 //Configure server authentication and client
authentication
OK
AT+QSSLCFG="ciphersuite",0,"0XFFFF" //Configure cipher suite.
OK
AT+QSSLOPEN=1,0,"220.180.239.212",8011,1 //Establish SSL connection with socket index as 1.
The connection is based on context 0, and is
transparent mode.
OK
<html>
<head>
<title>Quectel's Auto Parts-Order Results</title>
</head>
<body>
<h1>Quectel's Auto Parts</h1>
<h2>Order Results</h2>
<p>Order processed at </p><p>Your order is as follows: </p> message<br /> apple<br /> orange<br
/></body>
GSM_SSL_Application_Note 31 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
</html> //Server completes sending data.
ATO
CONNECT //Enter transparent mode.
OK
AT+QSECWRITE="RAM:client_cert.pem",1419,100 //Upload the client certificate to RAM.
CONNECT
<Input the client_cert.pem data, the size is 1419 bytes>
+QSECWRITE: 1419,618
OK
AT+QSECWRITE="RAM:client_key.pem",1679,100 //Upload the client private key to RAM.
CONNECT
<Input the client_key.pem data, the size is 1679 bytes>
+QSECWRITE: 1679,83a7
OK
GSM_SSL_Application_Note 32 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
which does not have a username and password.
OK
AT+QIREGAPP //Register to TCP/IP stack.
OK
AT+QIACT //Activate GPRS PDP context.
OK
AT+QILOCIP //Query local IP address.
100.119.144.3
//Step 3: Configure SSL version, cipher suite, server authentication and client authentication. Certificate
and private key are in RAM.
AT+QSSLCFG="ignorertctime",1 //Ignore the RTC time.
OK
AT+QSSLCFG="sslversion",0,4 //Configure SSL version.
OK
AT+QSSLCFG="ciphersuite",0,"0XFFFF" //Configure cipher suite.
OK
AT+QSSLCFG="seclevel",0,2 //Configure Server authentication and client
authentication.
OK
AT+QSECREAD="RAM:ca_cert.pem" //Check CA certificate is correct or not.
+QSECREAD: 1,4039
OK
AT+QSECREAD="RAM:client_cert.pem" //Check client certificate is correct or not.
+QSECREAD: 1,618
OK
AT+QSECREAD="RAM:client_key.pem" //Check client private key is correct or not.
+QSECREAD: 1,83a7
OK
AT+QSSLCFG="cacert",0,"RAM:ca_cert.pem" //Configure server root CA certificate.
OK
AT+QSSLCFG="clientcert",0,"RAM:client_cert.pem" //Configure client certificate.
OK
AT+QSSLCFG="clientkey",0,"RAM:client_key.pem" //Configure client key.
OK
GSM_SSL_Application_Note 33 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
`
CONNECT //Establish SSL connection successfully.
GET /processorder.php HTTP/1.1 //Input the data.
HOST: 220.180.239.201:8011
Accept: */*
User-Agent: QUECTEL_MODULE
CONNECT: KEEP-ALIVE //Complete data input.
<html>
<head>
<title>Quectel's Auto Parts-Order Results</title>
</head>
<body>
<h1>Quectel's Auto Parts</h1>
<h2>Order Results</h2>
<p>Order processed at </p><p>Your order is as follows: </p> message<br /> apple<br /> orange<br
/></body>
</html> //Server completes sending data.
ATO
CONNECT //Enter transparent mode.
GSM_SSL_Application_Note 34 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
4 Error Handling
If PDP context is failed to be activated by AT+QIACT, please check the following aspects:
1. Query whether the PS domain is attached by AT+CGATT?. If not, execute AT+CGATT=1 to attach
PS domain.
2. Query the AT+CGREG status by AT+CGREG? and make sure the PS domain is registered
3. Query the PDP context parameters by AT+QIREGAPP, 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.
If the result of checking is completed, but the result of executing AT+QIACT always fails, please reboot
the module to solve this issue. After rebooting the module, please check the above procedures at least
three times, at intervals of 10 minutes, to avoid frequent reboot of the module.
GSM_SSL_Application_Note 35 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
5 Appendix A Reference
Abbreviation Description
ME Mobile Equipment
MS Mobile Station
ID Identification
IP Internet Protocol
GSM_SSL_Application_Note 36 / 37
GSM/GPRS/GNSS Module Series
GSM SSL Application Note
TA Terminal Adapter
GSM_SSL_Application_Note 37 / 37