[WASI] Options for implementing wasi-tls proposal #109569
Labels
arch-wasm
WebAssembly architecture
area-System.Net.Security
os-wasi
Related to WASI variant of arch-wasm
Milestone
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:
The first was an implementation using the public API but done out of tree. We used that to prove we could use it with minimal changes to SqlClient.
The second is where I attempted to use the existing
SSLStream
design and PAL layer with the wasi-tls interfaces. I was able to get it to successfully work but found several issues with the approach.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'sSslStream
implementation, theSslStream
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):
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.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 tohttphandler
.Looking for some feedback on the various approaches.
/cc @pavelsavara @dicej
The text was updated successfully, but these errors were encountered: