SIM800 Series SSL Application Note V1.05
SIM800 Series SSL Application Note V1.05
_Application Note
GPRS Module
GENERAL NOTES
COPYRIGHT
www.simcom.com 2 / 25
SIM800 Series_SSL_Application Note_V1.05
About Document
Version History
Scope
This document presents the AT command of SSL operation and application examples. This document can
apply to SIM800 series modules with SSL function.
www.simcom.com 3 / 25
SIM800 Series_SSL_Application Note_V1.05
Contents
About Document.................................................................................................................................. 3
Version History.........................................................................................................................................................3
Scope........................................................................................................................................................................ 3
Contents................................................................................................................................................. 4
1 Introduction.................................................................................................................................... 5
1.1 Purpose of the document...........................................................................................................................5
1.2 Related Documents.................................................................................................................................... 5
1.3 Conventions and abbreviations................................................................................................................ 5
2 SSL Function..................................................................................................................................6
2.1 SSL Description...........................................................................................................................................6
2.2 HTTPS Description..................................................................................................................................... 6
2.3 FTPS Description........................................................................................................................................ 7
2.4 EMAIL Encrypted Transmission Description.......................................................................................... 7
3 AT command.................................................................................................................................. 8
3.1 AT+EMAILSSL Set Email to Use SSL Function.................................................................................... 8
3.2 AT+HTTPSSL Set HTTP to Use SSL Function...................................................................................9
3.3 AT+FTPSSL Set FTP to Use SSL Function...................................................................................... 10
3.4 AT+CIPSSL Set TCP to Use SSL Function.......................................................................................10
3.5 AT+SSLSETCERT Import SSL Client Client Certificate File with Private Key............................ 11
3.6 AT+SSLOPT SSL Option......................................................................................................................12
3.7 AT+SSLSETROOT Import SSL Root Certificate File...................................................................... 12
3.8 AT+SSLDEROOT Delete SSL Root Certificate File.........................................................................13
3.9 AT+SSLDECLI Delete SSL Client Certificate File............................................................................ 14
4 SSL Examples..............................................................................................................................15
4.1 EMAIL Send Encrypted Mail with Normal Port.................................................................................... 15
4.2 EMAIL Send Encrypted Mail with Encryption Port.............................................................................. 16
4.3 EMAIL Receive Encrypted Mail with Normal Port............................................................................... 16
4.4 EMAIL Receive Encrypted Mail with Encryption Port.........................................................................18
4.5 HTTPS Get Method with HTTPS........................................................................................................... 19
4.6 FTP Get Method with Implicit FTPS...................................................................................................... 20
4.7 Set FTP Get Method with Explicit FTPS...............................................................................................21
4.8 Establish a TCP Client Connection over SSL...................................................................................... 22
4.9 Establish a TCP Client Connection over SSL in Multi Connection...................................................22
4.10 Import a SSL Client Certificate File with Private Key..........................................................................24
4.11 Import a SSL Root Certificate File......................................................................................................... 24
4.12 Delete a SSL Root Certificate File......................................................................................................... 25
4.13 Delete a SSL Client Certificate File....................................................................................................... 25
www.simcom.com 4 / 25
SIM800 Series_SSL_Application Note_V1.05
1 Introduction
Based on module AT command manual, this document will introduce SSL operations, including HTTP,
EMAIL and FTP function.
Developers could understand and develop application quickly and efficiently based on this document.
Abbreviation Description
URC Unsolicited request code
TE Terminal Equipment
TA Terminal Adapter
DTE Data Terminal Equipment or plainly "the application" which is running on an
embedded system
DCE Data Communication Equipment or facsimile DCE(FAX modem, FAX board)
ME Mobile Equipment
MS Mobile Station
SSL Secure Socket Layer
TLS Transport Layer Security
www.simcom.com 5 / 25
SIM800 Series_SSL_Application Note_V1.05
2 SSL Function
Secure socket layer (SSL), a security protocol, is first put forward by Netscape at the same time as they
lunch the first version of Web Browser, the purpose is to provide security and data integrity for network
communication. SSL encrypts network connection at the transport layer.
SSL uses public key technology to ensure the confidentiality and reliability of communication between
applications, so that the communication between client and server application will not be intercepted by the
aggressor. It can be supported on both the server and the client ends, has become the industry standard
secure communication on the internet. The current Web browsers generally combine the HTTP and SSL,
enabling secure communication. This Agreement and its successor is TLS (Transport Layer Security).
TLS using the key algorithm provided endpoint authentication and secure communication on the Internet,
which is based on public key infrastructure (PKI). However, in the example of a typical implementation, only
the network service provider is reliable authentication, the client is not necessarily. This is because the
public key infrastructure common in commercial operation, electronic signature certificate is usually
required to pay for. Protocol is designed in a way to make the master-slave architecture application
communication itself prevent eavesdropping, tampering, and message forgery.
HTTPS is the HTTP channel which targets secure, in simple terms is safe version of HTTP. Added layer of
SSL below HTTP, security of HTTPS is based on SSL, so the details please see the SSL encryption.
It is a URI scheme (abstract identifier system), syntax similar to http: System. For secure HTTP data
transmission. HTTPS:URL shows that it uses HTTP, but HTTPS exists a default port different with HTTP
and has an encryption / authentication layer (between HTTP and TCP). This system was originally
developed by Netscape for providing authenticated and encrypted communication method, and now it is
widely used in security-sensitive communication on the World Wide Web, such as transaction payment.
www.simcom.com 6 / 25
SIM800 Series_SSL_Application Note_V1.05
FTPS is a multi-transmission protocol, equivalent to the encrypted version of the FTP. It is an enhanced
FTP protocol which uses standard FTP protocol and commands in the Secure Sockets Layer. It add SSL
security features for FTP protocol and data channels. FTPS is also known as "FTP-SSL" and
"FTP-over-SSL". SSL is a protocol which encrypts and decrypts data in secure connection between client
and an SSL-enabled server.
To receive Email, SIM800 series support SSL encrypted POP3 protocol which is called POP3S. It will use
special port, default port: 995. To send Email, SIM800 series use HTTPS communication, default port: 465.
SIM800 series also supports the use of ordinary port, through the STARTTLS (SMTP) and STLS (POP3) to
enable encryption transmission.
www.simcom.com 7 / 25
SIM800 Series_SSL_Application Note_V1.05
3 AT command
Command Description
AT+EMAILSSL Set EMAIL to use SSL function
AT+HTTPSSL Set HTTP to use SSL function
AT+FTPSSL Set FTP to use SSL function
AT+CIPSSL Set TCP to use SSL function
AT+SSLSETCERT Import SSL client certificate file
AT+SSLOPT SSL option
AT+SSLSETROOT Import SSL root certificate file
AT+SSLDEROOT Delete SSL root certificate file
AT+SSLDECLI Delete SSL Client Certificate File
OK
Write Command Response
AT+EMAILSSL=<n> OK
Parameter Saving Mode NO_SAVE
Max Response Time -
An error code will return if the SSL channel setup failure or
communication errors happened when sending mail:
+SMTPSEND: <code>
Reference
An error code when sign POP3 server:
+POP3IN: <code>
www.simcom.com 8 / 25
SIM800 Series_SSL_Application Note_V1.05
<code>
71 SSL failed to establish channels
72 SSL alert message with a level of fatal result in the immediate
termination of the connection.
Defined Values
OK
Read Command Response
AT+HTTPSSL? +HTTPSSL: <n>
OK
Write Command Response
AT+HTTPSSL=<n> OK
Parameter Saving Mode NO_SAVE
Max Response Time -
An error code will return if HTTPACTION command fail:
+HTTPACTION: <code>
<code>
Reference
605 SSL failed to establish channels
606 SSL alert message with a level of fatal result in the immediate
termination of the connection
Defined Values
www.simcom.com 9 / 25
SIM800 Series_SSL_Application Note_V1.05
OK
Read Command Response
AT+FTPSSL? +FTPSSL: <n>
OK
Set Command Response
AT+FTPSSL=<n> OK
Parameter Saving Mode NO_SAVE
Max Response Time -
An error code will return if FTP operation fail, case in FTPGET:
+FTPGET: <code>
<code> 80 SSL failed to establish channels
81 SSL alert message with a level of fatal result in the
Reference
immediate termination of the connection
82 FTP AUTH error
83 FTP PBSZ error
84 FTP PROT error
Defined Values
OK
Read Command Response
AT+CIPSSL? +CIPSSL: <n>
www.simcom.com 10 / 25
SIM800 Series_SSL_Application Note_V1.05
OK
Write Command Response
AT+CIPSSL=<n> OK
Parameter Saving Mode NO_SAVE
Max Response Time -
After set AT+CIPSSL=1, module will automatic begin SSL certificate
Reference after TCP connected
Currently, we just support SSL Client function.
Defined Values
3.5 AT+SSLSETCERT Import SSL Client Client Certificate File with Private
Key
AT+SSLSETCERT Import SSL Client Client Certificate File with Private Key
Test Command Response
AT+SSLSETCERT=? +SSLSETCERT: max length of field <file>,max length of field
<password>
OK
Write Command Response
AT+SSLSETCERT=<file>[,< OK
password>]
If import succeed
+SSLSETCERT: 0
If import failed
+SSLSETCERT: 1
Parameter Saving Mode NO_SAVE
Max Response Time -
Just one file can be imported. If import more than once, module will
Reference keep last imported file.
Support ".crt", ".cer" or "p12" certificate file.
Defined Values
www.simcom.com 11 / 25
SIM800 Series_SSL_Application Note_V1.05
characters.
<password> Password required to parse the certificate file. Alphanumeric ASCII
text string up to 32 characters.
OK
Read Command Response
AT+SSLOPT? +SSLOPT: 0,<enable>
+SSLOPT: 1,<enable>
OK
Write Command Response
AT+SSLOPT=<opt>,<enable OK
>
Parameter Saving Mode NO_SAVE
Max Response Time -
If need server authentication, please set AT+SSLOPT=0,0
If do not need server authentication, please set AT+SSLOPT=0,1
Reference
If need client authentication, please set AT+SSLOPT=1,1
If do not need client authentication, please set AT+SSLOPT=1,0
Defined Values
www.simcom.com 12 / 25
SIM800 Series_SSL_Application Note_V1.05
Defined Values
OK
Write Command Response
AT+SSLDEROOT=<filename If delete succeed
> +SSLDEROOT: 0
OK
If delete failed
+SSLDEROOT: 13 File does not exist
or
+SSLDEROOT: 42 Not enough permissions
OK
Parameter Saving Mode NO_SAVE
Max Response Time -
Reference
Defined Values
www.simcom.com 13 / 25
SIM800 Series_SSL_Application Note_V1.05
OK
Write Command Response
AT+SSLDECLI=<filename> If delete succeed
+SSLDECLI: 0
OK
Parameter Saving Mode NO_SAVE
Max Response Time -
Reference
Defined Values
www.simcom.com 14 / 25
SIM800 Series_SSL_Application Note_V1.05
4 SSL Examples
The following table provides some using method of the SSL function.
OK
AT+SMTPSEND Send the Email
OK
+SMTPSEND: 1
www.simcom.com 15 / 25
SIM800 Series_SSL_Application Note_V1.05
OK
AT+SMTPSEND //Send the Email
OK
+SMTPSEND: 1
www.simcom.com 16 / 25
SIM800 Series_SSL_Application Note_V1.05
+POP3IN: 1
AT+POP3NUM //Get Email number and total size
OK
+POP3NUM: 1,2,11124
AT+POP3LIST=1 //Get the specific Email’s size
OK
+POP3LIST: 1,1,5556
AT+POP3CMD=4,1 //Retrieve the specific Email
OK
+POP3CMD: 1
AT+POP3READ=1460 //Get the Email content
+POP3READ: 1,1460
…
OK
AT+POP3READ=1460
+POP3READ: 1,1460
…
OK
AT+POP3READ=1460 //The Email’s content is read completely
+POP3READ: 2,1183
…
OK
www.simcom.com 17 / 25
SIM800 Series_SSL_Application Note_V1.05
+POP3OUT: 1
+POP3IN: 1
AT+POP3NUM //Get Email number and total size
OK
+POP3NUM: 1,2,11124
AT+POP3LIST=1 //Get the specific Email’s size
OK
+POP3LIST: 1,1,5556
AT+POP3CMD=4,1 //Retrieve the specific Email
OK
+POP3CMD: 1
AT+POP3READ=1460 //Get the Email content
+POP3READ: 1,1460
…
www.simcom.com 18 / 25
SIM800 Series_SSL_Application Note_V1.05
OK
AT+POP3READ=1460
+POP3READ: 1,1460
…
OK
AT+POP3READ=1460 //The Email’s content is read completely
+POP3READ: 2,1183
…
OK
AT+POP3OUT //Log out POP3 SERVER
OK
+POP3OUT: 1
www.simcom.com 19 / 25
SIM800 Series_SSL_Application Note_V1.05
www.simcom.com 20 / 25
SIM800 Series_SSL_Application Note_V1.05
www.simcom.com 21 / 25
SIM800 Series_SSL_Application Note_V1.05
AT+CIPSSL=1 must be set first if customer want to start a TCP connection over SSL. Any TCP connection
established before AT+CIPSSL=1 will not try SSL certificate.
www.simcom.com 22 / 25
SIM800 Series_SSL_Application Note_V1.05
OK
AT+CIPMUX=1 //Enable multi connection
OK
AT+CSTT="CMNET" //Start task and set APN.
OK
AT+CIICR //Bring up wireless connection
OK (GPRS r CSD)
AT+CIFSR //Get local IP address
10.78.245.128
AT+CIPSTART=0,"TCP","116.228.221.51","850 //Establish a TCP connection, connection number
0" 0
OK
0,CONNECT OK
AT+CIPSSL=1 //Enable SSL function. Connection 0 will not start
OK SSL certificate
AT+CIPSTART=1,"TCP","116.228.221.51","960 //Establish a TCP connection, connection number
0" 1. SSL certificate finished.
OK
1,CONNECT OK
AT+CIPSEND=0 //Send data to connection 0
> TCP test
0,SEND OK
AT+CIPSEND=1 //Send data to connection 1
> TCP Over SSL test
1,SEND OK
+RECEIVE,0,17:
SIM800 TCP test //Received data from connection 0, data length 17
+RECEIVE,1,26: //Received data from connection 1, data length 26
SIM800 TCP Over SSL test
0,CLOSED //Connection 0 is closed by remote server
AT+CIPSTATUS //Query the current connection status
OK
STATE: IP PROCESSING
C:
0,0,"TCP","116.228.221.51","8500","CLOSED "
C:
1,0,"TCP","116.228.221.51","9600","CONNECT
ED "
C: 2,,"","","","INITIAL"
www.simcom.com 23 / 25
SIM800 Series_SSL_Application Note_V1.05
C: 3,,"","","","INITIAL"
C: 4,,"","","","INITIAL"
C: 5,,"","","","INITIAL"
+SSLSETCERT: 0
www.simcom.com 24 / 25
SIM800 Series_SSL_Application Note_V1.05
OK
AT+SSLDEROOT=1013 //Delete Certificate file 1013
+SSLDEROOT: 0 //Delete succeed
OK
OK
AT+SSLDECLI=1014 //Delete Certificate file 1014
+SSLDECLI: 0 //Delete succeed
OK
www.simcom.com 25 / 25