Skip to content

Add DTLS example#615

Open
peterharperuk wants to merge 2 commits into
raspberrypi:developfrom
peterharperuk:dtls_example
Open

Add DTLS example#615
peterharperuk wants to merge 2 commits into
raspberrypi:developfrom
peterharperuk:dtls_example

Conversation

@peterharperuk

Copy link
Copy Markdown
Contributor

The server listens for the client to connect and send it a string. It then sends the same text back to the client.

The server listens for the client to connect and send it a string.
It then sends the same text back to the client.
Comment thread pico_w/wifi/dtls/README.md Outdated
Comment thread pico_w/wifi/dtls/README.md Outdated
Comment thread pico_w/wifi/dtls/README.md Outdated
Comment thread pico_w/wifi/dtls/README.md Outdated
Comment thread pico_w/wifi/dtls/README.md Outdated
Comment thread pico_w/wifi/dtls/certs/makecerts.sh
Comment thread pico_w/wifi/dtls/certs/makecerts.sh
Comment thread pico_w/wifi/dtls/certs/makecerts.sh Outdated
Comment thread pico_w/wifi/dtls/dtls_common.c Outdated
@peterharperuk

Copy link
Copy Markdown
Contributor Author

Tested with mbedtls 3.x

@lurch lurch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A load of minor formatting-tweak suggestions, and a small tidy-up to makecerts.sh
Please note that I've not tried building or running any of the C code!

# Running the dtls examples

The client connects to a server and sends it a few lines of text which it expects to be sent back.
You can build and run the client and server examples on two Pico W devices, or to test with just one Pico W device, you can run the server or client on a Linux host.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can build and run the client and server examples on two Pico W devices, or to test with just one Pico W device, you can run the server or client on a Linux host.
You can build and run the client and server examples on two Pico W devices; or to test with just one Pico W device, you can run the server or client on a Linux host.


## Using openssl

The `host/server.sh` and `host/client.sh` scripts demonstrate how to use DTLS with openssl, although you will have to echo text manually.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `host/server.sh` and `host/client.sh` scripts demonstrate how to use DTLS with openssl, although you will have to echo text manually.
The `host/server.sh` and `host/client.sh` scripts demonstrate how to use DTLS with OpenSSL, although you will have to echo text manually.

The client connects to a server and sends it a few lines of text which it expects to be sent back.
You can build and run the client and server examples on two Pico W devices, or to test with just one Pico W device, you can run the server or client on a Linux host.

## Using openssl

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Using openssl
## Using OpenSSL

@@ -0,0 +1,63 @@
# Setup

These examples demonstrate how to use dtls via mbedtls on a Pico W device.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
These examples demonstrate how to use dtls via mbedtls on a Pico W device.
These examples demonstrate how to use DTLS via Mbed TLS on a Pico W device.

```
The examples should now build.

# Running the dtls examples

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Running the dtls examples
# Running the DTLS examples

@@ -0,0 +1,14 @@
#!/usr/bin/bash

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#!/usr/bin/bash
#!/bin/bash

@@ -0,0 +1,16 @@
#!/usr/bin/bash

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#!/usr/bin/bash
#!/bin/bash

SERVER_PORT=4433
SERVER_ADDR=${DTLS_SERVER:-$1}
if [ -z "$SERVER_ADDR" ]; then
echo Pass dtls server address as a parameter or set DTLS_SERVER

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo Pass dtls server address as a parameter or set DTLS_SERVER
echo Pass DTLS server address as a parameter or set DTLS_SERVER

fi
echo Connecting to $SERVER_ADDR
echo Enter some text to send. Enter \"Q\" to exit
openssl s_client -dtls -cert $CERT_FOLDER/client.crt -key $CERT_FOLDER/client.key -verifyCAfile $CERT_FOLDER/ca.crt -timeout -connect $SERVER_ADDR:${SERVER_PORT}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
openssl s_client -dtls -cert $CERT_FOLDER/client.crt -key $CERT_FOLDER/client.key -verifyCAfile $CERT_FOLDER/ca.crt -timeout -connect $SERVER_ADDR:${SERVER_PORT}
openssl s_client -dtls -cert $CERT_FOLDER/client.crt -key $CERT_FOLDER/client.key -verifyCAfile $CERT_FOLDER/ca.crt -timeout -connect $SERVER_ADDR:$SERVER_PORT


SERVER_ADDR=${DTLS_SERVER:-$1}
if [ -z "$SERVER_ADDR" ]; then
echo Pass dtls server address as a parameter or set DTLS_SERVER

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo Pass dtls server address as a parameter or set DTLS_SERVER
echo Pass DTLS server address as a parameter or set DTLS_SERVER

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants