{"id":22878337,"url":"https://github.com/nplab/dtls-examples","last_synced_at":"2025-10-15T11:06:26.182Z","repository":{"id":46184223,"uuid":"87935885","full_name":"nplab/DTLS-Examples","owner":"nplab","description":"Examples for DTLS via SCTP and UDP using OpenSSL","archived":false,"fork":false,"pushed_at":"2021-11-08T20:25:13.000Z","size":760,"stargazers_count":142,"open_issues_count":4,"forks_count":52,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T04:04:34.350Z","etag":null,"topics":["dtls","freebsd","linux","macos","openssl","sctp","tutorial","ubuntu","udp"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nplab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-11T13:13:32.000Z","updated_at":"2025-02-04T14:44:22.000Z","dependencies_parsed_at":"2022-08-30T05:05:16.907Z","dependency_job_id":null,"html_url":"https://github.com/nplab/DTLS-Examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nplab%2FDTLS-Examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nplab%2FDTLS-Examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nplab%2FDTLS-Examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nplab%2FDTLS-Examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nplab","download_url":"https://codeload.github.com/nplab/DTLS-Examples/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252788376,"owners_count":21804280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dtls","freebsd","linux","macos","openssl","sctp","tutorial","ubuntu","udp"],"created_at":"2024-12-13T16:20:43.393Z","updated_at":"2025-10-15T11:06:21.122Z","avatar_url":"https://github.com/nplab.png","language":"C","readme":"# DTLS Examples for OpenSSL\nThis repository contains examples for DTLS via SCTP and UDP.\nEach application in `src` can be used as client or server.\n\nOur examples are developed against the OpenSSL 1.1.x API.\n\n**Use OpenSSL Version 1.1.1a or higher.**\n\n## SCTP/UDP Examples\n**DTLS Echo Server and Client**  \nThis sample includes a multi-threaded echo server and client sending messages over an SCTP/UDP connection encrypted with DTLS.\n\n```\nUsage: dtls_(udp|sctp)_echo [options] [address]\nOptions:\n        -l      message length (default: 100 Bytes)\n        -L      local address\n        -p      port (default: 23232)\n        -n      number of messages to send (default: 5)\n        -v      verbose\n        -V      very verbose\n```\n\n**DTLS Character Generator Server and Client**  \nThis sample includes a multi-threaded character generator server and client sending as many messages as possible to each other over an SCTP/UDP connection encrypted with DTLS for a given time.\nStatistics how many messages have been sent and received and how many got lost are printed at the end.\n\n```\nUsage: dtls_(udp|sctp)_chargen [options] [address]\nOptions\n        -l      message length (default: 100 Bytes)\n        -L      local address\n        -s      streams (default: 5, sctp only)\n        -p      port (default: 23232)\n        -t      time to send (default: 10 sec)\n        -u      unordered (sctp only)\n        -v      verbose\n        -V      very verbose\n```\n\n**DTLS Discard Server and Client**  \nThis sample includes a multi-threaded discard server and client sending messages over an SCTP/UDP connection encrypted with DTLS.\n\n```\nUsage: dtls_(udp|sctp)_discard [options] [address]\nOptions:\n        -l      message length (Default: 100 Bytes)\n        -L      local address\n        -s      streams (default: 5, sctp only)\n        -p      port (default: 23232)\n        -t      time to send (Default: 10 sec)\n        -u      unordered (sctp only)\n        -v      verbose\n        -V      very verbose\n```\n\n## OS Requirements\n### FreeBSD\nSince FreeBSD 12.0, the built-in OpenSSL version is sufficient to run the UDP examples.  \nThe SCTP examples and older versions of FreeBSD require OpenSSL to be installed via `pkg` or from scratch.  \nFor FreeBSD 12.0 and 11.2, the OpenSSL 1.1.1 package from `pkg` is `openssl111`.  \n```\n$ pkg install openssl111\n```\n\n### Linux (Ubuntu)\nThe UDP examples should work with recent Linux distributions out-of-the-box.\nIn order to run the SCTP examples, OpenSSL has to be built from scratch with SCTP support.\n* Install the SCTP headers.\n```\nsudo apt-get install libsctp-dev\n```\n* Download the recent OpenSSL version.  \nThis example has been tested with OpenSSL 1.1.1a and Ubuntu 18.10.  \n* Configure OpenSSL to include SCTP support and (optionally) set a custom install prefix.  \n* Build and install OpenSSL.\n\n```\n$ ./config sctp --prefix=$HOME/my-openssl/\n$ make\n$ make install\n```\n\nIn addition to a loaded SCTP module, Linux requires SCTP AUTH support.\n```\n$ modprobe sctp\n$ sysctl -w net.sctp.auth_enable=1\n```\n\n### macOS\nIf you only want to run the UDP examples, prebuilt OpenSSL binaries can be installed via brew.\n```\n$ brew install openssl@1.1\n```\n\nA SCTP enabled OpenSSL version has to be compiled from source, follow the tutorial in the Linux section.\nSince macOS does not support SCTP out of the box, it is necessary to use the SCTP NKE.\n\n## Build the Examples\nBefore calling `make` in the `src` directory, it may be necessary to specify custom *library* and *include* paths.\nThis is either done by modifying the *Makefile* or by providing the path as a command line argument.\nIt is also possible to only build SCTP or UDP examples.\n\n```\n$ make\n$ make sctp  # only SCTP examples\n$ make udp  # only UDP examples\n```\n\n## OpenSSL Certificates\nIn order to run the example programs, the required server and client certificates should be located in a `certs` subfolder.\n* client-cert.pem\n* client-key.pem\n* server-cert.pem\n* server-key.pem\n\nThe following commands create signed certificates for client and server of the samples above.\n```\ntouch ca-db-index\necho 01 \u003e ca-db-serial\n\n# Certificate Authority\nopenssl req -nodes -x509 -newkey rsa:2048 -days 365 -keyout ca-key.pem -out ca-cert.pem\n\n# Server Certificate\nopenssl req -nodes -new -newkey rsa:2048 -keyout server-key.pem -out server.csr\n\n# Sign Server Certificate\nopenssl ca -config ca.conf -days 365 -in server.csr -out server-cert.pem\n\n# Client Certificate\nopenssl req -nodes -new -newkey rsa:2048 -keyout client-key.pem -out client.csr\n\n# Sign Client Certificate\nopenssl ca -config ca.conf -days 365 -in client.csr -out client-cert.pem\n```\n\nYou can create your own [ca.conf](ca.conf) file or use a minimal sample.\n\n## Usage with OpenSSL s_client / s_server\nThe examples are not limited to be used with each other, they may also be used with the built-in OpenSSL application.\n\nThe example below starts a SCTP echo server.\nThe client connects via OpenSSL's `s_client` application and sends input read from `stdin` to the server.\nThe server echos received messages.\n\n```\n$ dtls_sctp_echo -V -L 127.0.0.1\n```\n```\n$ openssl s_client -sctp -dtls -connect 127.0.0.1:23232\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnplab%2Fdtls-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnplab%2Fdtls-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnplab%2Fdtls-examples/lists"}