rvolosatovs opened PR #12174 from rvolosatovs:feat/wasip3-tls to bytecodealliance:main:
This is a draft implementation, which will be developed alongside the spec PR (will open shortly and add ref)
refs #12102
rvolosatovs edited PR #12174:
This is a draft implementation, which will be developed alongside the spec PR (https://github.com/WebAssembly/wasi-tls/pull/17)
refs #12102
rvolosatovs updated PR #12174.
rvolosatovs updated PR #12174.
rvolosatovs updated PR #12174.
rvolosatovs has marked PR #12174 as ready for review.
rvolosatovs requested wasmtime-wasi-reviewers for a review on PR #12174.
rvolosatovs requested wasmtime-core-reviewers for a review on PR #12174.
rvolosatovs requested cfallin for a review on PR #12174.
rvolosatovs requested wasmtime-default-reviewers for a review on PR #12174.
rvolosatovs updated PR #12174.
rvolosatovs edited PR #12174:
This is the implementation of current p3 draft https://github.com/WebAssembly/wasi-tls/pull/17
refs #12102
rvolosatovs updated PR #12174.
rvolosatovs updated PR #12174.
badeend submitted PR review.
badeend created PR review comment:
Do you want me to cut a new release?
badeend created PR review comment:
The P2 bindings are built on top of the
TlsProvider/TlsTransport/TlsStreamabstractions defined incrates/wasi-tls/src/lib.rs. Those abstractions make the bindings agnostic to the actual underlying TLS implementation. Currently, wasmtime has three backends for the user to choose from:
rustls(the default of thiswasmtime-wasi-tlscrate)wasmtime-wasi-tls-nativetlswasmtime-wasi-tls-opensslThe P3 bindings in this PR bypass the existing abstractions and target
rustlsdirectly.Do you think it is possible to make the P3 bindings backend-agnostic as well? Doesn't necessarily have to be part of this PR right now
rvolosatovs submitted PR review.
rvolosatovs created PR review comment:
That would be awesome!
rvolosatovs submitted PR review.
rvolosatovs created PR review comment:
I would rather start with the simplest approach using the library directly. It should definitely be possible to abstract the implementation here, however there might be some challenges here, as we can't quite directly use Tokio I/O abstractions here due to the lack of (CM) cancellation support in Tokio.
Let's figure this out in a follow-up?
rvolosatovs edited PR review comment.
rvolosatovs edited PR review comment.
rvolosatovs edited PR review comment.
badeend submitted PR review.
badeend created PR review comment:
Sure :+1:
badeend submitted PR review.
badeend created PR review comment:
v0.2.0-draft+6781ae2
rvolosatovs updated PR #12174.
rvolosatovs requested badeend for a review on PR #12174.
alexcrichton created PR review comment:
I realize that this is duplicating the p2 tests already present, but given that this is basically modeled as "run the thing" that could also be modeled as a
p3_cli_*test run as part oftests/all/cli_tests.rswhere it bottoms out inwasmtime run -S... foo.wasm.I might recommend moving more in that direction than having librarified test here to make it a bit more uniform to run tests
alexcrichton created PR review comment:
I'm not sure if this was copied from elsewhere, but personally I'd say that these macros are probably overkill given the that they're mostly one-liners around
table.$method(thing)and the type annotations onResource<T>is typically enough to guide everything type-inference wide. The benefit of these macros would be the extra error context information, but given how rarely these will all be triggered I'm not sure it's worth the complexity.
alexcrichton submitted PR review:
I'm finding
host/mod.rspretty gnarly here especially withWakerlogic and such to the point that I'd have to dig more into what rustls is offering here to double-check all the logic. That being said I'd also be fine to defer to @badeend in terms of review on that.I'll note though that this is a pretty beefy implementation with relatively light testing. Would it be possible to enhance the tests here or does the current test basically not pass unless all the bits and bobs are present?
badeend submitted PR review.
badeend created PR review comment:
The WIT file mentions:
Closing the
cleartextstream will cause aclose_notifypacket to be emitted on the returned output stream.I don't see where graceful shutdown is handled in the current implementation. I would expect a call to
send_close_notifysomewhere
badeend created PR review comment:
I notice
process_new_packetsappear multiple times in this file.The rustls documentation mentions that this method should only be called after a successful call to
Connection::read_tls. This lines up with how e.g. tokio-rustls does it, where the termprocess_new_packetsappears only once in the entire crate, right after the call toread_tls.I think only
CiphertextConsumerhas to useprocess_new_packets, and the other ones can get by without:
- The returned
statevariable is used as a heuristic for the capacity of.as_direct(..). A fixed size could work too, optionally bounded bydst.remaining().peer_has_closedis also surfaced from the regularreadcall, when it returns Ok(0)
badeend created PR review comment:
The
wasi-tlscreate already has a bunch of these types incrates/wasi-tls/src/lib.rs. E.g.WasiTls<'a>,WasiTlsCtx,WasiTlsCtxBuilder. Can the P3 implementation make use of those existing ones?
badeend created PR review comment:
connectshould perform the handshake and not return before that has succeeded or failed. But in its current form this method doesn't do any I/O.
badeend created PR review comment:
The error returned by
process_new_packetsonly affects theread_tlsside. The other directions may still continue to work. From rustls docs:After an error is received from process_new_packets, you should not call read_tls any more (it will fill up buffers to no purpose). However, you may call the other methods on the connection, including write, send_close_notify, and write_tls. Most likely you will want to call write_tls to send any alerts queued by the error and then close the underlying connection.
So I don't know if waking everybody up is the right thing to do.
Last updated: Feb 24 2026 at 06:21 UTC