Skip to content

[WASI] Options for implementing wasi-tls proposal #109569

Open
@jsturtevant

Description

@jsturtevant

There is a proposal for adding tls support in wasi-sockets. After adding socket support it makes sense to enable more scenarios with were tls is required. One instance would be using SqlClient.

We've done a few prototypes to figure out how this might work with dotnet:

In the second approach there is a mismatch between the level of the wasi-tls design and the existing SslStream implementation. wasi-tls operates on a transparent stream delegating the handling to the Host. In dotnet's SslStream implementation, the SslStream class handles all of the I/O, tls frame processing, and sends the frames one by one to the SSL context. Since we don't have that level of the SSL context exposed via the wasi-tls interface, and all the processing is happening asynchronously on the host side there is an issue of knowing when all the content has been sent to the host a fully processed by the SSL context and sent back to the guest to be forwarded on the socket layer.

I can think of a few of options to move forward (maybe more if I am missing something, which I might be):

  1. Make changes to the wasi-tls interface to expose a different type of interface that would support the current approach in dotnet's SslStream class. The downside to this is that thee wasi-tls interface is simple and easy to understand as designed today. It keeps the details out of the guest implementation and lets the host handle the complexity.
  2. Create a special case in the SslStream library for WASI that by-passes the current PAL abstraction around SSL and fills in the parts that make sense for wasi-tls in the public API. This would be somewhat similar to the first prototype implementation and be similar to httphandler.
  3. Refactor parts of the current PAL SSL abstraction to support this SSL stream. Downside is that all of the PAL layer is sync and we also still have the challenge of know when we've sent enough information to the underlying SSL context to get a response back.

Looking for some feedback on the various approaches.

/cc @pavelsavara @dicej

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions