Quectel BC660K-GL SSL Application Note V1.0
Quectel BC660K-GL SSL Application Note V1.0
Quectel BC660K-GL SSL Application Note V1.0
Application Note
Version: 1.0
Date: 2021-12-29
Status: Released
BC660K-GL_SSL_Application_Note 1 / 24
NB-IoT Module Series
At Quectel, our aim is to provide timely and comprehensive services to our customers. If you
require any assistance, please contact our headquarters:
Legal Notices
We offer information as a service to you. The provided information is based on your requirements and we
make every effort to ensure its quality. You agree that you are responsible for using independent analysis
and evaluation in designing intended products, and we provide reference designs for illustrative purposes
only. Before using any hardware, software or service guided by this document, please read this notice
carefully. Even though we employ commercially reasonable efforts to provide the best possible
experience, you hereby acknowledge and agree that this document and related services hereunder are
provided to you on an “as available” basis. We may revise or restate this document from time to time at
our sole discretion without any prior notice to you.
Copyright
Our and third-party products hereunder may contain copyrighted material. Such copyrighted material shall
not be copied, reproduced, distributed, merged, published, translated, or modified without prior written
consent. We and the third party have exclusive rights over copyrighted material. No license shall be
granted or conveyed under any patents, copyrights, trademarks, or service mark rights. To avoid
ambiguities, purchasing in any form cannot be deemed as granting a license other than the normal
non-exclusive, royalty-free license to use the material. We reserve the right to take legal action for
noncompliance with abovementioned requirements, unauthorized use, or other illegal or malicious use of
the material.
BC660K-GL_SSL_Application_Note 1 / 24
NB-IoT Module Series
Trademarks
Except as otherwise set forth herein, nothing in this document shall be construed as conferring any rights
to use any trademark, trade name or name, abbreviation, or counterfeit product thereof owned by Quectel
or any third party in advertising, publicity, or other aspects.
Third-Party Rights
This document may refer to hardware, software and/or documentation owned by one or more third parties
(“third-party materials”). Use of such third-party materials shall be governed by all restrictions and
obligations applicable thereto.
We make no warranty or representation, either express or implied, regarding the third-party materials,
including but not limited to any implied or statutory, warranties of merchantability or fitness for a particular
purpose, quiet enjoyment, system integration, information accuracy, and non-infringement of any
third-party intellectual property rights with regard to the licensed technology or use thereof. Nothing herein
constitutes a representation or warranty by us to either develop, enhance, modify, distribute, market, sell,
offer for sale, or otherwise maintain production of any our products or any other hardware, software,
device, tool, information, or product. We moreover disclaim any and all warranties arising from the course
of dealing or usage of trade.
Privacy Policy
To implement module functionality, certain device data are uploaded to Quectel’s or third-party’s servers,
including carriers, chipset suppliers or customer-designated servers. Quectel, strictly abiding by the
relevant laws and regulations, shall retain, use, disclose or otherwise process relevant data for the
purpose of performing the service only or as permitted by applicable laws. Before data interaction with
third parties, please be informed of their privacy and data security policy.
Disclaimer
a) We acknowledge no liability for any injury or damage arising from the reliance upon the information.
b) We shall bear no liability resulting from any inaccuracies or omissions, or from the use of the
information contained herein.
c) While we have made every effort to ensure that the functions and features under development are
free from errors, it is possible that they could contain errors, inaccuracies, and omissions. Unless
otherwise provided by valid agreement, we make no warranties of any kind, either implied or express,
and exclude all liability for any loss or damage suffered in connection with the use of features and
functions under development, to the maximum extent permitted by law, regardless of whether such
loss or damage may have been foreseeable.
d) We are not responsible for the accessibility, safety, accuracy, availability, legality, or completeness of
information, advertising, commercial offers, products, services, and materials on third-party websites
and third-party resources.
Copyright © Quectel Wireless Solutions Co., Ltd. 2021. All rights reserved.
BC660K-GL_SSL_Application_Note 2 / 24
NB-IoT Module Series
Revision History
BC660K-GL_SSL_Application_Note 3 / 24
NB-IoT Module Series
Contents
1 Introduction .......................................................................................................................................... 6
1.1. SSL Versions ................................................................................................................................ 6
1.2. SSL Cipher Suites ........................................................................................................................ 6
1.3. DTLS Versions ............................................................................................................................. 7
3 Example .............................................................................................................................................. 20
3.1. SSL Function of Two-Way Authentication .................................................................................. 20
3.2. DTLS Function of Two-Way Authentication ............................................................................... 21
BC660K-GL_SSL_Application_Note 4 / 24
NB-IoT Module Series
Table Index
BC660K-GL_SSL_Application_Note 5 / 24
NB-IoT Module Series
1 Introduction
To keep the communication secure and prevent sensitive data from being eavesdropped, tampered, or
forged during the communication process, SSL is used to safeguard the communication between the
server and the client by using encryption algorithms.
This document describes how to apply the SSL function of Quectel BC660K-GL module.
SSL Version
TLS1.0
TLS1.1
TLS1.2
The following table shows SSL cipher suites supported by Quectel BC660K-GL module. Please refer to
https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml for details of the cipher suites.
0X002F TLS_RSA_WITH_AES_128_CBC_SHA
BC660K-GL_SSL_Application_Note 6 / 24
NB-IoT Module Series
0X0035 TLS_RSA_WITH_AES_256_CBC_SHA
0X000A TLS_RSA_WITH_3DES_EDE_CBC_SHA
0X00FF TLS_EMPTY_RENEGOTIATION_INFO_SCSV
DTLS Version
DTLS1.0
DTLS1.2
BC660K-GL_SSL_Application_Note 7 / 24
NB-IoT Module Series
2.1.1. Definitions
All command lines must start with AT or at and end with <CR>. Information responses and result codes
always start and end with a carriage return character and a line feed character:
<CR><LF><response><CR><LF>. In tables presenting commands and responses throughout this
document, only the commands and responses are presented, and <CR> and <LF> are deliberately
omitted.
BC660K-GL_SSL_Application_Note 8 / 24
NB-IoT Module Series
The AT command examples in this document are provided to help you learn about how to use the AT
commands introduced herein. The examples, however, should not be taken as Quectel’s
recommendation or suggestions about how you should design a program flow or what status you should
set the module into. Sometimes multiple examples may be provided for one AT command. However, this
does not mean that there exists a correlation among these examples and that they should be executed in
a given sequence.
BC660K-GL_SSL_Application_Note 9 / 24
NB-IoT Module Series
OK
Write Command Response
Query all current settings of the +QSSLCFG: <contextID>,<connectID>,"seclevel",<secl
specified context evel>
AT+QSSLCFG=<contextID>,<connec +QSSLCFG: <contextID>,<connectID>,"sslversion",<S
tID> SL_version>
+QSSLCFG: <contextID>,<connectID>,"dataformat",<s
end_data_format>,<recv_data_format>
+QSSLCFG: <contextID>,<connectID>,"timeout",<time
out>
+QSSLCFG: <contextID>,<connectID>,"debug",<debug
_level>
+QSSLCFG: <contextID>,<connectID>,"cacert",<check
sum>
+QSSLCFG: <contextID>,<connectID>,"clientcert",<che
cksum>
+QSSLCFG: <contextID>,<connectID>,"clientkey",<che
cksum>
+QSSLCFG: <contextID>,<connectID>,"dtls",<DTLS_en
able>
+QSSLCFG: <contextID>,<connectID>,"dtlsversion",<D
TLS_version>
OK
Or
ERROR
Write Command Response
Configure the authentication mode for If the optional parameter is omitted, query the current
the specified SSL context setting:
AT+QSSLCFG=<contextID>,<connec +QSSLCFG: <contextID>,<connectID>,"seclevel",<secl
tID>,"seclevel"[,<seclevel>] evel>
OK
BC660K-GL_SSL_Application_Note 10 / 24
NB-IoT Module Series
OK
BC660K-GL_SSL_Application_Note 11 / 24
NB-IoT Module Series
OK
OK
OK
BC660K-GL_SSL_Application_Note 12 / 24
NB-IoT Module Series
OK
OK
OK
BC660K-GL_SSL_Application_Note 13 / 24
NB-IoT Module Series
Parameter
<contextID> Integer type. SSL context ID. Range: 0–10 (currently only 0 is supported).
<connectID> Integer type. SSL connect ID. Range: 0–4 (currently only 0 is supported).
<seclevel> Integer type. The authentication mode.
0 No authentication
1 Perform server authentication
2 Perform server and client authentication if requested by the remote
server
<SSL_version> Integer type. SSL version.
1 TLS 1.0
2 TLS 1.1
3 TLS 1.2
4 All protocols are supported, the specific protocol version used needs
to be negotiated with the server.
<send_data_format> Integer type. The format of the sent data.
0 Text format
1 Hex format
<recv_data_format> Integer type. The format of the received data.
0 Text format
1 Hex format
<timeout> Integer type. Timeout value of connection or message delivery. Range:
10–300. Default value: 90. Unit: second.
<debug_level> Integer type. The printable debug log level.
0 No debug log
1 Error debug log
2 State debug log
3 Info debug log
4 Detail debug log
<checksum> Integer type. The length of certificate. Unit: byte.
<DTLS_enable> Integer type. Enable or disable DTLS feature.
0 Disable DTLS feature.
1 Enable DTLS feature .
<DTLS_version> Integer type. DTLS version.
0 DTLS 1.0
1 DTLS 1.2
2 All protocols are supported, the specific protocol version used needs
to be negotiated with the server.
BC660K-GL_SSL_Application_Note 14 / 24
NB-IoT Module Series
NOTE
1. <debug_level> is used during debugging only. And the bigger the value is, the more log will be
generated.
2. If <seclevel> is set to 0, no certificates need to be configured. If <seclevel> is set to 1, server CA
certificate needs to be configured. If <seclevel> is set to 2, server CA certificate, client certificate and
client private key need to be configured.
3. The configuration of <timeout> is only valid for TLS connection and invalid for DTLS connection.
OK
Read Command Response
AT+QSSLOPEN? OK
Write Command Response
AT+QSSLOPEN=<contextID>,<conne OK
ctID>,<host_name>,<port>,<connect
_mode> +QSSLOPEN: <contextID>,<connectID>,<err>
Parameter
<contextID> Integer type. SSL context ID. Range: 0–10 (currently only 0 is supported).
<connectID> Integer type. SSL connect ID. Range: 0–4 (currently only 0 is supported).
<host_name> String type. IP address or domain name of SSL server. Maximum length: 150
bytes.
<port> Integer type. Port number of the remote server. Range: 1–65535.
BC660K-GL_SSL_Application_Note 15 / 24
NB-IoT Module Series
This command sends data through the SSL connection after the connection is established.
OK
Read Command Response
AT+QSSLSEND? OK
Write Command Response
Send variable-length data >
AT+QSSLSEND=<contextID>,<conne After the above response, the module enters data mode and
ctID> the data to be sent can be inputted directly. Tap “CTRL” + “Z”
to send the data or tap “Esc” to cancel the operation.
+QSSLSEND: <contextID>,<connectID>,<err>
BC660K-GL_SSL_Application_Note 16 / 24
NB-IoT Module Series
+QSSLSEND: <contextID>,<connectID>,<err>
Parameter
<contextID> Integer type. SSL context ID. Range: 0–10 (currently only 0 is supported).
<connectID> Integer type. SSL connect ID. Range: 0–4 (currently only 0 is supported).
<send_length> Integer type. The length of the data to be sent. Range: 1–1024. Unit: byte.
<err> Integer type. The result of connection. 0 indicates a successful operation and any
other value indicates an error. Please refer to Chapter 4 for more details.
NOTE
When <send_data_format> in AT+QSSLCFG is set to 1 (hex format), the character length of the data to
be inputted after executing AT+QSSLSEND=<contextID>,<connectID>,<send_length> must be twice
of <send_length> value.
This command closes an SSL connection. If all SSL connections of an SSL context are closed, the
module will release the SSL context.
OK
Read Command Response
AT+QSSLCLOSE? OK
Write Command Response
AT+QSSLCLOSE=<contextID>,<con OK
nectID>
+QSSLCLOSE: <contextID>,<connectID>,<err>
BC660K-GL_SSL_Application_Note 17 / 24
NB-IoT Module Series
Parameter
<contextID> Integer type. SSL context ID. Range: 0–10 (currently only 0 is supported).
<connectID> Integer type. SSL connect ID. The range is 0–4 (currently only 0 is supported).
<err> Result code. 0 indicates a successful operation and any other value indicates an
error. Please refer to Chapter 4 for more details.
SSL URCs begin with +QSSLURC: and they are mainly used to notify the host of incoming data or
disconnected SSL connection.
Parameter
<contextID> Integer type. SSL context ID. Range: 0–10 (currently only 0 is supported).
<connectID> Integer type. SSL connect ID. Range: 0–4 (currently only 0 is supported).
<length> Integer type. The length of data. Range: 1–1400. Unit: byte.
<data> String type. The incoming data.
BC660K-GL_SSL_Application_Note 18 / 24
NB-IoT Module Series
The URC notifies the host that the SSL connection has been disconnected. When this URC is reported,
the module closes the SSL connection automatically, and the host does not need to execute
AT+QSSLCLOSE to close the SSL connection.
Parameter
<contextID> Integer type. SSL context ID. Range: 0–10 (currently only 0 is supported).
<connectID> Integer type. SSL connect ID. Range: 0–4 (currently only 0 is supported).
BC660K-GL_SSL_Application_Note 19 / 24
NB-IoT Module Series
3 Example
OK
AT+QSSLCFG=0,0,"clientcert" //Configure client certificate
>
//After the response >, input content of the client certificate in PEM format, tap “CTRL” + “Z” to send.
+QSSLCFG: 0,0,"clientcert",1224
OK
AT+QSSLCFG=0,0,"clientkey" //Configure client private key
>
//After the response >, input content of the client private key in PEM format, tap “CTRL” + “Z” to send.
+QSSLCFG: 0,0,"clientkey",1679
OK
AT+QSSLOPEN=0,0,"hf.quectel.com",8164,0 //Open an SSL server connection
OK
+QSSLOPEN: 0,0,0
AT+QSSLSEND=0,0 //Send data to SSL server
>
//After the response >, input the data to be sent and tap “CTRL” + “Z” to send.
OK
+QSSLSEND: 0,0,0
BC660K-GL_SSL_Application_Note 20 / 24
NB-IoT Module Series
+QSSLCLOSE: 0,0,0
AT+QSCLK=1 //Enable light sleep and deep sleep and wake up by
PSM_EINT (falling edge)
OK
OK
AT+QSSLCFG=0,0,"clientcert" //Configure client certificate
>
//After the response >, input content of the client certificate in PEM format, tap “CTRL” + “Z” to send.
+QSSLCFG: 0,0,"clientcert",1224
OK
AT+QSSLCFG=0,0,"clientkey" //Configure client private key
>
//After the response >, input content of the client private key in PEM format, tap “CTRL” + “Z” to send.
+QSSLCFG: 0,0,"clientkey",1679
OK
AT+QSSLOPEN=0,0,"hf.quectel.com",8164,0 //Open an SSL server connection
OK
+QSSLOPEN: 0,0,0
BC660K-GL_SSL_Application_Note 21 / 24
NB-IoT Module Series
+QSSLSEND: 0,0,0
+QSSLCLOSE: 0,0,0
AT+QSCLK=1 //Enable light sleep and deep sleep and wake up by
PSM_EINT (falling edge)
OK
NOTE
BC660K-GL_SSL_Application_Note 22 / 24
NB-IoT Module Series
4 Result Codes
<err> Description
0 Successful operation
-1 Exception error
-2 Connection error
-3 Certificate error
-4 Key error
-5 Cipher error
-6 State error
-7 Time out
-9 Other errors
BC660K-GL_SSL_Application_Note 23 / 24
NB-IoT Module Series
5 Appendix References
Document Name
[1] Quectel_BC660K-GL_AT_Commands_Manual
Abbreviation Description
CA Certificate Authority
IP Internet Protocol
TA Terminal Adapter
BC660K-GL_SSL_Application_Note 24 / 24