How To: Secure e-mail client (SMTP + SSL) with KSDK1.3 + WolfSSL for FRDM-K64F

Document created by Denis Shimizu Employee on Jan 26, 2016Last modified by ebiz_ws_prod on Aug 6, 2018
Version 15Show Document
  • View in full screen mode

This is an adaptation I made for the original SMTP protocol implementation provided with the KSDK1.3, with the addition of the secure connection using WolfSSL.

The example software is currently ported to the FRDM-K64F Kinetis board but it can be implemented for other boards.This demo sends a e-mail using the Gmail SMTP server ( , port 465) through a SSL channel.


How to run the example:


1 - Download the example software attached. You will need to have KDS 3.0 and KSDK1.3 previously installed on the machine.

2 - In KDS, go to File -> Import, select the folder Project of Projects -> Existing Project Sets, then open the file mqx_smtp_ssl_demo.wsd located in the folder \SMTP_SSL_demo_KSDK_1.3.0\examples\frdmk64f\demo_apps\security\smtp_wolfssl\smtp_wolfssl_mqx\kds

3- Build all the libraries and run the example project.

4- To allow SMTP + SSL , you will need to change your Gmail account settings

5- Using a Serial terminal (115200 bps,8N1) connected to the OpenSDA CDC interface (COM port), connect it to see the shell.Type ipconfig init and ipconfig dhcp to init the Ethernet interface and get a valid IP from the router.


6- Type help to see all the commands available.

7- To send a e-mail using the secure channel, you will need a valid gmail account and use the command:       

sec_email -f < > -t <> -s <> [-u <Username>] [-p <Password>] [-j <"email subject">] [-m <"text of email message"]>


For example:       

sec_email -f -t -s -u -p mypassword -j "email subject" -m "text of email message"


Some additional notes:


- The Certificate Authority (CA) file from Equifax, used for Gmail, is decoded in hexadecimal to a c array and it is located in the file rtcs_smtp_ssl.c , in the \middleware\tcpip\rtcs\source\apps folder:



- To connect to other servers with SSL support, you will need to obtain a valid Certificate Authority file for this server. You can do it in three steps: 1) Verify what is the certificate authority used by the server. One way to do it is using OpenSSL ( OpenSSL  ) ,  with s_client and the option -showcerts to see the server certificates and check the certificate Authority.Gmail uses Equifax as CA 2) After you know the Certificate Authority of the server, you can get the certificate file in pem file format on a e-mail client for PC (e.g. Outlook).In this case , Outlook has the Equifax certificate file.All the certificate files need to start with -----BEGIN CERTIFICATE----- and to finish with -----END CERTIFICATE----- ,as below 3) You need to convert your CA file to a c language array. You can use Bin2h to do the task.


     PEM file generated by Equifax before to be converted to a c array


All the files used to build the demo are included on the file attached. The SSL connection using the WolfSSL software is made on the file rtcs_smtp_ssl.c.

1 person found this helpful