Skip to content

src,lib: implement experimental DTLS API#63182

Open
jasnell wants to merge 1 commit intonodejs:mainfrom
jasnell:jasnell/dtls
Open

src,lib: implement experimental DTLS API#63182
jasnell wants to merge 1 commit intonodejs:mainfrom
jasnell:jasnell/dtls

Conversation

@jasnell
Copy link
Copy Markdown
Member

@jasnell jasnell commented May 8, 2026

Decided to take a short break from the work on QUIC to implement a DTLS API, mostly just for the enjoyment of it. Very experimental at this point but the basic API is there (inspired by the QUIC API work).

The implementation is based on OpenSSL's built-in DTLS support and no other dependencies are required.

DTLS is a datagram-based version of TLS that is used for things like WebRTC and CoAP. It provides similar security guarantees as TLS but is designed to work over UDP instead of TCP.

This shouldn't be considered ready for production but it is a good starting point for experimentation and feedback.

./configure --experimental-dtls
make -j{nproc}
./node --experimental-dtls my-dtls-app.js

Fixes: #61630

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/config
  • @nodejs/gyp
  • @nodejs/loaders
  • @nodejs/startup

@jasnell jasnell requested a review from mcollina May 8, 2026 04:04
@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels May 8, 2026
@jasnell
Copy link
Copy Markdown
Member Author

jasnell commented May 8, 2026

@nodejs/net

Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

+1, good idea

@jasnell jasnell force-pushed the jasnell/dtls branch 3 times, most recently from a09cc0b to 9bd9284 Compare May 8, 2026 18:45
@jasnell jasnell added net Issues and PRs related to the net subsystem. experimental Issues and PRs related to experimental features. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. dont-land-on-v25.x PRs that should not land on the v25.x-staging branch and should not be released in v25.x. dont-land-on-v26.x PRs that should not land on the v26.x-staging branch and should not be released in v26.x. large-pr dtls labels May 8, 2026
@jasnell jasnell marked this pull request as ready for review May 8, 2026 18:46
@jasnell jasnell requested a review from mcollina May 8, 2026 18:46
Decided to take a short break from the work on QUIC
to implement a DTLS API. Very experimental at this
point but the basic API is there (inspired by the
QUIC API work).

The implementation is based on OpenSSL's built-in
DTLS support and no other dependencies are required.

DTLS is a datagram-based version of TLS that is used
for things like WebRTC and CoAP. It provides similar
security guarantees as TLS but is designed to work over
UDP instead of TCP.

This shouldn't be considered ready for production
but it is a good starting point for experimentation
and feedback.

```bash
./configure --experimental-dtls
make -j{nproc}
./node --experimental-dtls my-dtls-app.js
```

Signed-off-by: James M Snell <[email protected]>
Assisted-by: Opencode:Opus 4.6
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

❌ Patch coverage is 46.33867% with 469 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.54%. Comparing base (2b6ce13) to head (9efa2c1).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/dtls/dtls.js 37.73% 391 Missing ⚠️
lib/internal/dtls/state.js 58.12% 67 Missing ⚠️
lib/dtls.js 75.00% 9 Missing ⚠️
lib/internal/process/pre_execution.js 80.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63182      +/-   ##
==========================================
- Coverage   90.06%   89.54%   -0.52%     
==========================================
  Files         713      712       -1     
  Lines      224942   218960    -5982     
  Branches    42534    42527       -7     
==========================================
- Hits       202590   196073    -6517     
- Misses      14147    14688     +541     
+ Partials     8205     8199       -6     
Files with missing lines Coverage Δ
lib/internal/bootstrap/node.js 98.97% <100.00%> (+0.01%) ⬆️
lib/internal/dtls/symbols.js 100.00% <100.00%> (ø)
lib/internal/modules/cjs/loader.js 98.04% <100.00%> (-0.23%) ⬇️
src/node_binding.cc 83.13% <ø> (+0.39%) ⬆️
src/node_builtins.cc 71.59% <100.00%> (-4.51%) ⬇️
src/node_options.cc 76.63% <100.00%> (+0.02%) ⬆️
src/node_options.h 98.00% <100.00%> (+0.01%) ⬆️
lib/internal/process/pre_execution.js 97.79% <80.00%> (-0.60%) ⬇️
lib/dtls.js 75.00% <75.00%> (ø)
lib/internal/dtls/state.js 58.12% <58.12%> (ø)
... and 1 more

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. dont-land-on-v25.x PRs that should not land on the v25.x-staging branch and should not be released in v25.x. dont-land-on-v26.x PRs that should not land on the v26.x-staging branch and should not be released in v26.x. dtls experimental Issues and PRs related to experimental features. large-pr lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. net Issues and PRs related to the net subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DTLS

3 participants