Connecting to an SMTP Server Using the Freescale NanoSSL Client



Similar documents
Connecting Low-Cost External Electrodes to MED-EKG

Using WinUSB in a Visual Studio Project with Freescale USB device controller

Windows 7: Using USB TAP on a Classic CodeWarrior Installation (MGT V9.2 DSC V8.3)

How To Build A Project On An Eclipse Powerbook For Anarc (Powerbook) On An Ipa (Powerpoint) On A Microcontroller (Powerboard) On Microcontrollers (Powerstation) On Your Microcontroller 2 (Powerclock

IRTC Compensation and 1 Hz Clock Generation

Installation of the MMA955xL CodeWarrior Service Pack Author: Fengyi Li Application Engineer

Cyclic Redundant Checker Calculation on Power Architecture Technology and Comparison of Big-Endian Versus Little-Endian

Software Real Time Clock Implementation on MC9S08LG32

How To Control A Motor Control On An Hvac Platform

Freescale Embedded GUI Converter Utility 2.0 Quick User Guide

etpu Host Interface by:

Flexible Active Shutter Control Interface using the MC1323x

How to Convert 3-Axis Directions and Swap X-Y Axis of Accelerometer Data within Android Driver by: Gang Chen Field Applications Engineer

Using the Performance Monitor Unit on the e200z760n3 Power Architecture Core

Blood Pressure Monitor Using Flexis QE128 Gabriel Sanchez RTAC Americas

Local Interconnect Network (LIN) Physical Interface

Handling Freescale Pressure Sensors

Point-of-Sale (POS) Users Guide Lech José Olmedo Guerrero Jaime Herrerro Gallardo RTAC Americas

Hardware Configurations for the i.mx Family USB Modules

MC13783 Buck and Boost Inductor Sizing

Improving Embedded Software Test Effectiveness in Automotive Applications

Freescale Semiconductor. Integrated Silicon Pressure Sensor. On-Chip Signal Conditioned, Temperature Compensated and Calibrated MPX4080D.

Generate Makefiles from Command Line Support in Eclipse-Based CodeWarrior Software

Understanding LCD Memory and Bus Bandwidth Requirements ColdFire, LCD, and Crossbar Switch

Programming Audio Applications in the i.mx21 MC9328MX21

Initializing the TSEC Controller

User Interface Design using CGI Programming and Boa Web Server on M5249C3 Board

How To Measure Power Of A Permanent Magnet Synchronous Motor

Performance Monitor on PowerQUICC II Pro Processors

USB HID bootloader for the MC9S08JM60

Using eflexpwm Module for ADC Synchronization in MC56F82xx and MC56F84xx Family of Digital Signal Controllers

MCF54418 NAND Flash Controller

PowerQUICC II Pro (MPC83xx) PCI Agent Initialization

NOT RECOMMENDED FOR NEW DESIGN

MLPPP in the Evolving Radio Access Network

VLE 16-bit and 32-bit Instruction Length Decode Algorithm

Freescale Semiconductor. Integrated Silicon Pressure Sensor. On-Chip Signal Conditioned, Temperature Compensated and Calibrated MPX5500.

Data Movement Between Big-Endian and Little-Endian Devices

Techniques and Tools for Software Analysis

Using the Kinetis Security and Flash Protection Features

NOT RECOMMENDED FOR NEW DESIGN

VGA Output using TV-Out Extension Solution i.mx21

Processor Expert Software Microcontrollers Driver Suite Getting Started Guide

PQ-MDS-T1 Module. HW Getting Started Guide. Contents. About This Document. Required Reading. Definitions, Acronyms, and Abbreviations

How To Fit A 2Mm Exposed Pad To A Dfn Package

Developing an Application for the i.mx Devices on the Linux Platform

Freescale Variable Key Security Protocol Transmitter User s Guide by: Ioseph Martínez and Christian Michel Applications Engineering - RTAC Americas

Emulated EEPROM Implementation in Dual Flash Architecture on MC9S08LG32 With Demo Description

i.mx28 Ethernet Performance on Linux

ColdFire Security SEC and Hardware Encryption Acceleration Overview

NOT RECOMMENDED FOR NEW DESIGN

Configuring the FlexTimer for Position and Speed Measurement with an Encoder

Ref Parameters Symbol Conditions Min Typ Max Units. Standby μa. 3 Range kpa. 4 Resolution 0.15 kpa. 5 Accuracy -20ºC to 85ºC ±1 kpa

Using Program Memory As Data Memory. 1. Introduction Program Memory and Data. Contents. Memory. Freescale Semiconductor Application Note

MSC8156 and MSC8157 PCI Express Performance

3-Phase BLDC Motor Control with Hall Sensors Using 56800/E Digital Signal Controllers

Understanding Pressure and Pressure Measurement

Installing Service Pack Updater Archive for CodeWarrior Tools (Windows and Linux) Quick Start

Robust Over-the-Air Firmware Updates Using Program Flash Memory Swap on Kinetis Microcontrollers

CodeWarrior Development Studio Floating Licensing Quick Start

Enhanced Serial Interface Mapping

Detecting a CPM Overload on the PowerQUICC II

Implementing Positioning Algorithms Using Accelerometers

Efficient Low-Level Software Development for the i.mx Platform

Using XGATE to Implement LIN Communication on HCS12X Daniel Malik 8/16-Bit Products Division East Kilbride, Scotland

Avoiding Read While Write Errors When Developing In-Software Flash Programming Applications for Kinetis and ColdFire+ MCUs

Real Time Development of MC Applications using the PC Master Software Visualization Tool. 1. Introduction. 2. Development of Motor Control.

MPC8245/MPC8241 Memory Clock Design Guidelines: Part 1

Pressure Freescale Semiconductor

Adding SDIO Wi-Fi Solution to i.mx Windows CE 5.0/Windows CE 6.0

RF Power Field Effect Transistors N- Channel Enhancement- Mode Lateral MOSFETs

Using the High Input Voltage Charger for Single Cell Li-Ion Batteries (KIT34671EPEVBE)

White Paper. Freescale s Embedded Hypervisor for QorIQ P4 Series Communications Platform

Freescale Semiconductor. Integrated Silicon Pressure Sensor

Installing Service Pack Updater Archive for CodeWarrior Tools (Windows and Linux) Quick Start

Motion and Freefall Detection Using the MMA8451, 2, 3Q

MPXAZ6115A MPXHZ6115A SERIES. Freescale Semiconductor Technical Data. MPXAZ6115A Rev 4, 01/2007

ITU-T V.42bis Data Dictionary Search on the StarCore SC140/SC1400 Cores

KIT34845EPEVME Evaluation Board

How To Improve Performance On A P4080 Processor

DRM for Driver Information System on S12G128. Reference Design

3-Phase BLDC Motor Control with Hall Sensors Using the MC56F8013

Genesi Pegasos II Setup

How to Do EEPROM Emulation Using Double Flash Array on MC9S08LC60 Ronald Gonzalez and Tatiana Orofino RTAC Americas

CodeWarrior Development Studio for Freescale S12(X) Microcontrollers Quick Start

Frequency Analysis in the Industrial Market Using Accelerometer Sensors

Creating your own Tower Module Custom Relay Module Example

AND8365/D. 125 kbps with AMIS-4168x APPLICATION NOTE

AND9190/D. Vertical Timing Optimization for Interline CCD Image Sensors APPLICATION NOTE

LOW POWER SCHOTTKY. GUARANTEED OPERATING RANGES ORDERING INFORMATION

Using the HC08 SCI Module

USB Mass Storage Device Host Bootloader

ULN2803A ULN2804A OCTAL PERIPHERAL DRIVER ARRAYS

AND9015. A Solution for Peak EMI Reduction with Spread Spectrum Clock Generators APPLICATION NOTE. Prepared by: Apps Team, BIDC ON Semiconductor

Solder Joint Temperature and Package Peak Temperature Determining Thermal Limits during Soldering

User Guide. Introduction. HCS12PLLCALUG/D Rev. 0, 12/2002. HCS12 PLL Component Calculator

AND8336. Design Examples of On Board Dual Supply Voltage Logic Translators. Prepared by: Jim Lepkowski ON Semiconductor.

Transcription:

Freescale Semiconductor Document Number: AN4363 Application Note Rev. 0, 10/2011 Connecting to an SMTP Server Using the Freescale NanoSSL Client by: Paolo Alcantara Microcontroller Solutions Group 1 Introduction This document describes the necessary steps for connecting to a Simple Mail Transfer Protocol (SMTP) server from a Freescale NanoSSL client using the Secure Socket Layer (SSL) protocol. Freescale NanoSSL is an inexpensive royaltyfree product intended for use with Freescale MQX. At the end of the process described in this document, the application sends an email that can be used for logging, alerts, notifications, status, or as an input to another embedded application. Contents 1 Introduction...1 2 Overview of the SMTP client application...2 3 Conclusion...10 1.1 Scope This document presents information about SMTP for an application that connects to a secure Gmail account using SSL. An example project can be obtained from the NanoSSL product after purchase. A web link is provided in the first reference at the end of this application note. This document is intended to be used by all software development engineers, test engineers, and anyone else who is implementing an SMTP client using Freescale NanoSSL for an embedded device. 2011 Freescale Semiconductor, Inc.

2 Overview of the SMTP client application The SMTP client application connects to a remote SMTP server, in this case, Gmail (smtp.gmail.com). Communication is over SSL, a cryptographic protocol that provides security over the Internet. For SSL communication, the Freescale NanoSSL client software is used. The RTOS that works with this software is Freescale MQX. The API used in the application code is documented and can be obtained as soon as the software is acquired, making it easy to understand. The SMTP server used can be changed to a customized SSL server by following the source code and this document. 2.1 SMTP client application details The following sections address details that need to be considered for connection with an SMTP client application. 2.1.1 Basic SMTP over SSL The complete application can be found in the mss_ssl_client.c application software. It performs the following actions: 1. Starts a basic socket and requests that the SSL protocol starts using the SMTP protocol 2. Starts an SSL socket and continues using the SMTP protocol over SSL 3. Requests that an email be sent, fills the email, and sends it to the SMTP server 4. Closes the connection. Further information about SMTP can be found in application note AN3930, "Email Client Using MCF51CN Family and FreeRTOS." 2.1.2 Certificates used by the SSL client Certificates are digital information that contains a digital signature from an authority that certifies the information. During the SSL protocol, the server certificate must be verified. As part of this verification, the SSL client compares its local SSL server certificate against the received SSL server certificate. If they match, communication continues; otherwise, it fails. Parsing the received SSL server certificate means that there may be more than one certificate present during the communication. In this case, each one of the certificates is linked together as a certificate chain, shown in the diagram below. The last certificate in the chain is the root certificate. This last certificate is used by the NanoSSL client software to validate the SSL communication. Freescale NanoSSL client software expects the application to provide a valid Certificate Authority (CA) certificate for checking during SSL communication. The following section shows how to determine the name of the certificate and how it can be obtained for the SMTP client application. 2 Freescale Semiconductor, Inc.

Certificate #1 Certificate #2 Root Certificate Issuer Issuer Issuer Subject Subject Subject Public key Public key Public key Signature Signature Signature Figure 1. Certificate chain Certificates used by the SMTP server have an expiration date, which means that at some point, the certificate used by the application must be updated with a new one. The following steps must be considered during this process. 2.1.2.1 How to get a certificate from an SMTP server 1. Configure an email desktop application with the settings of the remote SMTP server. In this example, Microsoft Outlook Express is used as a Gmail server as shown in the figures below. Figure 2. Outlook Express settings (1) Freescale Semiconductor, Inc. 3

Figure 3. Outlook Express settings (2) 2. Send an email from the desktop email application. Check to see whether the email is received at the remote email account. If it doesn t work, the SMTP server might not be available through a desktop email application such as Outlook. 3. Repeat the previous step, taking a TCP/IP log file from the remote SMTP server. In this example, the Outlook Express application is logged using the Wireshark network protocol analyzer. The following figure shows an example: 4 Freescale Semiconductor, Inc.

Figure 4. Wireshark filter 4. TCP communication between the email reader and remote SMTP server is only necessary for the next step. In this example, filter communication by using ip.addr == 72.14.213.109 as shown in the following figure. Figure 5. Wireshark filter 5. The log file should now show SSL communication. In the following example, SMTP is shown instead. To change, decode communication to SSL by right-clicking and selecting Decode as as shown in the following figures. Figure 5: Wireshark filter Freescale Semiconductor, Inc. 5

Figure 6. Decoding TCP communication as SSL in Wireshark Figure 7. Selecting SSL as the decoding protocol 6. Now, browse the last certificate. In the following figure, the last certificate is outlined in red. 6 Freescale Semiconductor, Inc.

Figure 8. Using the last certificate from the chain 7. Extract the certificate string from the browsed certificate using this path: [Last Certificate] Signed Certificate Issuer rdnsequence [OrganizationalUnitName] Item DirectoryString printablestring Certificate Name. In this example, the string is Equifax Secure Certificate Authority, as shown in the figure below. Figure 9. Extracting a string from the last certificate 8. Details about the certificate expiration date (validity) can also be extracted from last step. Freescale Semiconductor, Inc. 7

9. Use the string to get the certificate from the web or a web browser application. In this example, the certificate is from Mozilla Firefox, as shown in the following figure. Figure 10. Extracting a certificate from Mozilla Firefox (1) 8 Freescale Semiconductor, Inc.

Figure 11. Extracting a certificate from Mozilla Firefox (2) Freescale Semiconductor, Inc. 9

Conclusion Figure 12. Extracting a certificate from Mozilla Firefox (3) 10. Open the extracted DER certificate and store the hexadecimal data as a C-language array in the source code. You can use a trial software package like Hex Editor Neo to get the hexadecimal information. An example is shown in the following figure. Figure 13. Certificate array to be used in the application software 11. The extracted C-language array must be inserted in the mss_ssl_client.c source as shown in the Gmail example code. This is used by the Freescale NanoSSL client example software. 3 Conclusion This document describes how to send an email using an SMTP server through an SSL connection. Following the principles described above, you can explore several options for sending information from an embedded device, such as logging files, events, alerts, and so on. Further options, like WiFi, can be added to explore wireless options. 10 Freescale Semiconductor, Inc.

Conclusion 3.1 Reporting problems Issues and suggestions about this document and the associated drivers should be provided through the Freescale support webpage at www.freescale.com/support. Please reference this application note. 3.2 Considerations and references Find the newest information about the Freescale NanoSSL client on the Freescale Semiconductor (www.freescale.com) and Freescale NanoSSL (www.freescale.com/nanossl) home pages. The software associated with this application note (AN4363SW) can be found on the Downloads area of the Freescale NanoSSL home page. It includes only the SMTP application; Freescale NanoSSL is not included. For further information about the SMTP protocol, see AN3930, "Email Client Using MCF51CN Family and FreeRTOS." Freescale Semiconductor, Inc. 11

How to Reach Us: Home Page: www.freescale.com Web Support: http://www.freescale.com/support USA/Europe or Locations Not Listed: Freescale Semiconductor Technical Information Center, EL516 2100 East Elliot Road Tempe, Arizona 85284 +1-800-521-6274 or +1-480-768-2130 www.freescale.com/support Europe, Middle East, and Africa: Freescale Halbleiter Deutschland GmbH Technical Information Center Schatzbogen 7 81829 Muenchen, Germany +44 1296 380 456 (English) +46 8 52200080 (English) +49 89 92103 559 (German) +33 1 69 35 48 48 (French) www.freescale.com/support Japan: Freescale Semiconductor Japan Ltd. Headquarters ARCO Tower 15F 1-8-1, Shimo-Meguro, Meguro-ku, Tokyo 153-0064 Japan 0120 191014 or +81 3 5437 9125 support.japan@freescale.com Asia/Pacific: Freescale Semiconductor China Ltd. Exchange Building 23F No. 118 Jianguo Road Chaoyang District Beijing 100022 China +86 10 5879 8000 support.asia@freescale.com For Literature Requests Only: Freescale Semiconductor Literature Distribution Center 1-800-441-2447 or +1-303-675-2140 Fax: +1-303-675-2150 LDCForFreescaleSemiconductor@hibbertgroup.com Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductors products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document. Freescale Semiconductor reserves the right to make changes without further notice to any products herein. Freescale Semiconductor makes no warranty, representation, or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any liability, including without limitation consequential or incidental damages. "Typical" parameters that may be provided in Freescale Semiconductor data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including "Typicals", must be validated for each customer application by customer's technical experts. Freescale Semiconductor does not convey any license under its patent rights nor the rights of others. Freescale Semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur. Should Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application, Buyer shall indemnify Freescale Semiconductor and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claims alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part. RoHS-compliant and/or Pb-free versions of Freescale products have the functionality and electrical characteristics as their non-rohs-complaint and/or non-pb-free counterparts. For further information, see http://www.freescale.com or contact your Freescale sales representative. For information on Freescale's Environmental Products program, go to http://www.freescale.com/epp. Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. 2011 Freescale Semiconductor, Inc. Document Number: AN4363 Rev. 0, 10/2011