Add DTLS example#615
Open
peterharperuk wants to merge 2 commits into
Open
Conversation
The server listens for the client to connect and send it a string. It then sends the same text back to the client.
lurch
reviewed
Feb 21, 2025
lurch
reviewed
Feb 21, 2025
lurch
reviewed
Feb 21, 2025
lurch
reviewed
Feb 21, 2025
lurch
reviewed
Feb 21, 2025
lurch
reviewed
Feb 21, 2025
lurch
reviewed
Feb 21, 2025
lurch
reviewed
Feb 21, 2025
lurch
reviewed
Feb 21, 2025
Contributor
Author
|
Tested with mbedtls 3.x |
lurch
reviewed
Jul 11, 2025
lurch
left a comment
Contributor
There was a problem hiding this comment.
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. |
Contributor
There was a problem hiding this comment.
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. |
Contributor
There was a problem hiding this comment.
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 |
Contributor
There was a problem hiding this comment.
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. | |||
Contributor
There was a problem hiding this comment.
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 |
Contributor
There was a problem hiding this comment.
Suggested change
| # Running the dtls examples | |
| # Running the DTLS examples |
| @@ -0,0 +1,14 @@ | |||
| #!/usr/bin/bash | |||
Contributor
There was a problem hiding this comment.
Suggested change
| #!/usr/bin/bash | |
| #!/bin/bash |
| @@ -0,0 +1,16 @@ | |||
| #!/usr/bin/bash | |||
Contributor
There was a problem hiding this comment.
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 |
Contributor
There was a problem hiding this comment.
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} |
Contributor
There was a problem hiding this comment.
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 |
Contributor
There was a problem hiding this comment.
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The server listens for the client to connect and send it a string. It then sends the same text back to the client.