1- Apache Mynewt examples
2- =============
1+ # Apache Mynewt examples
32
43## Overview
54
6- It provides follows mynewt packages .
5+ [ Mynewt ] ( https://mynewt.apache.org ) is a security-oriented OS for IoT .
76
8- - apps/wolfsslclienttlsmn
9- - client-tls simple example ssl/tls client application for mn_socket.
7+ WolfSSL integration with the Mynewt OS may be found in the ` /IDE/mynewt `
8+ directory in the ` wolfssl ` source-tree. Support includes the wolfCrypt test
9+ application which demonstrates the cryptography provided by the wolfCrypt
10+ component of wolfSSL.
1011
11- ## Prepare
12+ ` wolfssl ` provides the following mynewt packages:
1213
13- install ` newt ` command by referencing below document.
14+ - _ crypto/wolfsslwolfssl_ - wolfSSL SSL/TLS and wolfCrypt cryptography library
15+ - _ apps/wolfcrypttest_ - wolfCrypt unit test application
16+
17+ The examples for wolfSSL and Mynewt found in the ` mynewt ` directory of
18+ ` wolfssl-examples ` (this directory) includes demonstration of additional
19+ wolfSSL capabilities such as TLS.
20+
21+ ` wolfssl-examples ` provides the follows mynewt packages:
22+
23+ - _ apps/wolfsslclienttlsmn_ - simple client TLS application for ` mn_socket `
24+
25+ The Mynewt OS has a primary command-line tool called ` newt ` which is used to
26+ configure and build Mynewt for targets. Targets include a simulated environment
27+ for Linux hosts, which will be used by the wolfSSL applications. Mynewt installs
28+ to a project directory from which the ` newt ` command is run.
29+
30+ ## Setup
31+
32+ 1 . Install Mynewt ` newt ` command using instructions found at:
1433
1534http://mynewt.apache.org/latest/get_started/native_install/index.html
1635
17- ## How to setup
36+ 2 . Create Mynewt project directory (e.g. ` mynewt ` ).
37+
38+ In parent folder of new Mynewt project directory:
39+
40+ ```
41+ $ newt new mynewt
42+ ```
43+
44+ NOTE: If problems are encountered creating a new Mynewt project an alternative:
1845
19- ### delopy wolfssl source to mynewt project
20- Specify the path of the mynewt project and execute ` mynewt/setup.sh ` .
46+ ```
47+ $ git clone git@github.com:apache/mynewt-blinky.git mynewt
48+ $ cd mynewt
49+ $ newt upgrade
50+ ```
51+
52+ 3 . Install wolfSSL support into Mynewt project.
2153
22- ``` bash
23- ./mynewt/setup.sh /path/to/myproject_path
54+ In the ` wolfssl/IDE/mynewt ` directory:
55+
56+ ```
57+ $ ./setup path-to-mynewt
2458```
2559
26- This script will deploy wolfssl's mynewt package described in the Overview to the mynewt project.
60+ 4 . Install wolfSSL examples support into Mynewt project.
2761
28- ## example setting example applications to targets
62+ In the ` wolfssl-examples/mynewt ` directory:
2963
30- This section explains how to set wolfssl example application to target device.
64+ ```
65+ $ ./setup path-to-mynewt
66+ ```
67+
68+ ## Configuration
3169
32- Please execute follows commands at only once .
70+ 1 . Create client TLS application for simulator target .
3371
34- create wolfsslclienttlsmn_sim that is simulator device for unit test of client-tls.
72+ In Mynewt project directory:
3573
3674```
37- cd /path/to/myproject_path
38- newt target delete wolfsslclienttlsmn_sim
39- newt target create wolfsslclienttlsmn_sim
40- newt target set wolfsslclienttlsmn_sim app=apps/wolfsslclienttlsmn
41- newt target set wolfsslclienttlsmn_sim bsp=@apache-mynewt-core/hw/bsp/native
42- newt target set wolfsslclienttlsmn_sim build_profile=debug
75+ $ newt target create wolfsslclienttlsmn_sim
76+ $ newt target set wolfsslclienttlsmn_sim app=apps/wolfsslclienttlsmn
77+ $ newt target set wolfsslclienttlsmn_sim bsp=@apache-mynewt-core/hw/bsp/native
78+ $ newt target set wolfsslclienttlsmn_sim build_profile=debug
4379```
4480
81+ ## Build and Run
4582
46- ## build & test
83+ 1 . Build client TLS application.
4784
48- build and execute wolfsslclienttlsmn_sim
85+ In Mynewt project directory:
4986
5087```
51- newt clean wolfsslclienttlsmn_sim
52- newt build wolfsslclienttlsmn_sim
53- ./bin/targets/wolfsslclienttlsmn_sim/app/apps/wolfsslclienttlsmn/wolfsslclienttlsmn.elf
88+ $ newt clean wolfsslclienttlsmn_sim
89+ $ newt build wolfsslclienttlsmn_sim
5490```
5591
56- ## Usage
57- ### connect ` wolfsslclienttlsmn `
92+ 2 . Run client TLS application
5893
59- ` wolfssl clienttlsmn.elf ` displays tty file path.
60- be able to connect ` wolfsslclienttlsmn.elf ` by using terminal softwre such as ` screen ` or ` kermit ` .
94+ In Mynewt project directory:
6195
62- ### command list
96+ ```
97+ $ ./bin/targets/wolfsslclienttlsmn_sim/app/apps/wolfsslclienttlsmn/wolfsslclienttlsmn.elf
98+ ```
6399
64- ` wolfsslclienttlsmn ` has below commands.
100+ The Mynewt simulator will display the linux host device where the application's
101+ uart is accessible via a terminal emulator program such as ` picocom ` , ` screen ` or
102+ ` kermit ` . For example: ` uart0 at /dev/pts/3 `
103+
104+ 3 . Connect terminal emulator (e.g. picocom) to simulated application UART.
105+
106+ ```
107+ $ sudo picocom -b 115200 /dev/pts/3
108+ ```
109+
110+ The application will display the Mynewt shell prompt ` compat> ` (press ENTER if
111+ shell prompt is not visiable). Entering ` help ` will display commands available,
112+ including the ` wolfssl ` command with represents the client TLS application.
113+
114+ ## Usage
115+
116+ ### Command list
117+
118+ The client TLS application ` wolfssl ` has the following commands:
65119
66120
67121| command | argument | describe | example |
68122| ---------| ----------------------------------| ----------------------------| ---------------------------------------|
69123| time | "unix timestamp" | To set the time | "time 1532616682" |
70124| net | udp | create udp socket | "net udp" |
71125| net | tcp | create tcp socket | "net tcp" |
72- | net | connect "ipaddress" port | connect "ipaddress" | "net connect 93.184.216.34" 443 |
126+ | net | connect "ipaddress" port | connect "ipaddress" | "net connect 93.184.216.34 443" |
73127| net | close | close socket | "net close" |
74128| net | send "string" "ipaddress" "port" | send string | "net send "GET \r\n" 93.184.216.34 80 |
75129| net | recv "ipaddress" | recv from ipaddress | "net recv 93.184.216.34 80 |
@@ -79,24 +133,79 @@ be able to connect `wolfsslclienttlsmn.elf` by using terminal softwre such as `s
79133| wolfssl | read | recv via ssl | "wolfssl recv" |
80134| wolfssl | clear | finish wolfssl library | "wolfssl clear" |
81135
82- ### command examples
83- get ` index.html ` from ` www.example.com:443 `
136+ ### Command examples
137+ Get ` index.html ` from ` www.example.com:443 ` (i.e. ` 93.184.216.34:443 ` ) using
138+ Mynewt TCP networking and the wolfSSL TLS and crypto.
139+
140+ At the Mynewt ` compat> ` shell prompt:
84141
85142```
86143net tcp
87- net connect
144+ net connect 93.184.216.34 443
88145wolfssl init
89146wolfssl connect
90- wolfssl write
147+ wolfssl write "GET /"
91148wolfssl read
92149wolfssl clear
93150net close
94151```
95152
96- # jenkins script
97- ## setup for jenkins node
153+ The resulting application output should be similar to the following:
154+
155+ ```
156+ compat> net tcp
157+ 001143 mn_socket(TCP) = 0 566b7800
158+ compat> net connect 93.184.216.34 443
159+ 005078 93.184.216.34/443
160+ 005078 mn_connect() = 0
161+ compat> net_test_writable 0 - 0
162+ wolfssl init
163+ 005853 wolfssl contexts are initialized
164+ 005854 wolfSSL ctx initialize
165+ compat> wolfssl connect
166+ 006517 wolfSSL_connect() = 1
167+ compat> wolfssl write "GET /"
168+ 009182 wolfSSL_write() = 4L
169+ compat> wolfssl read
170+ 010564 HTTP/1.0 501 Not Implemented
171+ Content-Type: text/html
172+ Content-Length: 357
173+ Connection: close
174+ Date: Wed, 12 Apr 2023 14:49:27 <?xml version="1.0" encoding="iso-8859-1"?>
175+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
176+ "http://wwwitle>501 - Not Implemented</title>
177+ </head>
178+ <body>
179+ <h1>501 - Not Implemented</h1>
180+ </body>
181+ </html>
182+
183+ 010578
184+ 010578 ERROR: wolfSSL_read rc:-1 err:6
185+ compat> wolfssl clear
186+ 012551 clear wolfssl contexts
187+ 012553 wolfSSL ctx clear
188+ compat> net close
189+ 012893 mn_close() = 0
190+ compat>
191+ ```
192+
193+ NOTE: The server-side connection close after reception of data results in the
194+ read error.
195+
196+ ## Notes
197+
198+ - Client TLS example run on _ Ubuntu 22.04LTS_ host with _ wolfSSL v5.6.0_ .
199+
200+ - See ` wolfssl/IDE/mynewt/README.md ` for details on wolfSSL integration and use
201+ of the wolfCrypt test application.
202+
203+
204+ # Jenkins script (test automation)
205+
206+ ## Setup for jenkins node
98207
99- install below softwares
208+ Install:
100209
101210- git
102211- expect
@@ -106,7 +215,7 @@ install below softwares
106215
107216## Usage
108217
109- execute ` jenkins.sh ` script on jenkins.
218+ Execute ` jenkins.sh ` script on jenkins.
110219
111220```
112221./mynewt/jenkins.sh
0 commit comments