typelevel / typelevel/fs2

API to directly open TLS connections, instead of upgrading an existing socket

Open
#3,138 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Scala
Stars
2.5k
Forks
636
Avg merge
2d 4h
Merged PRs (30d)
7

Description

Background: currently to get a TLSSocket, you first create a non-encrypted Socket, then upgrade it via TLSContext to get a TLSSocket. This proposal is for new TLSContext APIs to directly create client/server TLSSockets.

Motivation:

  • On Native, s2n-tls is capable of interfacing directly with the underlying socket's file descriptor. This should have higher performance and is probably easier to implement than redirecting it through an FS2 Socket.

    Even more compelling, s2n-tls also supports using Kernel TLS, where all the encryption/decryption happens in kernel-space. This minimizes data copies.

  • On JS, the upgrade is implemented by a costly Node.js Socket <-> FS2 Socket <-> Node.js Socket <-> Node.js TLS Socket <-> FS2 TLS Socket conversion. In Node.js it is possible to directly open TLS connections/servers directly, and thus skip a few layers of conversion.

I'm not aware of any motivation to do this on the JVM, at least with the JDK. Probably a hypothetical Netty-based TLSContext could take advantage of this.

Questions:

  1. Could e.g. Ember and Skunk take advantage of such an API, instead of manually upgrading?
  2. Alternatively, could we make these optimizations within the upgrade mechanism, without exposing a new API? Seems hard, since in theory the user could continue doing things with the raw Socket even after upgrading it. If we assume that won't happen, then maybe it can work.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing TLSContext APIs and the socket-upgrade mechanism described in the issue, then investigate whether Ember and Skunk could use direct client/server TLSSocket creation. The issue needs a decided API or optimization scope before implementation can be considered done.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.