Skip to content

Add DTLS example #615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

peterharperuk
Copy link
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.
@peterharperuk
Copy link
Contributor Author

Tested with mbedtls 3.x

Copy link
Contributor

@lurch lurch left a comment

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
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
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
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
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
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
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
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
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
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
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