-
Notifications
You must be signed in to change notification settings - Fork 929
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
base: develop
Are you sure you want to change the base?
Add DTLS example #615
Conversation
The server listens for the client to connect and send it a string. It then sends the same text back to the client.
Tested with mbedtls 3.x |
There was a problem hiding this 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Using openssl | |
## Using OpenSSL |
@@ -0,0 +1,63 @@ | |||
# Setup | |||
|
|||
These examples demonstrate how to use dtls via mbedtls on a Pico W device. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Running the dtls examples | |
# Running the DTLS examples |
@@ -0,0 +1,14 @@ | |||
#!/usr/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#!/usr/bin/bash | |
#!/bin/bash |
@@ -0,0 +1,16 @@ | |||
#!/usr/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#!/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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo Pass dtls server address as a parameter or set DTLS_SERVER | |
echo Pass DTLS server address as a parameter or set DTLS_SERVER |
The server listens for the client to connect and send it a string. It then sends the same text back to the client.