Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
wolfcrypt-tls-tokio
Async TLS for tokio backed by wolfSSL.
TlsStream<IO> implements tokio::io::AsyncRead + AsyncWrite.
Why
The same reasons to choose wolfcrypt-tls for blocking I/O apply here — FIPS
140-3 validation, small footprint, no OpenSSL — but for async Rust with tokio:
- FIPS 140-3 — the only async tokio TLS crate backed by a FIPS-validated crypto module (commercial license; contact wolfSSL)
- tokio-rustls-compatible API —
TlsConnector/TlsAcceptor/TlsStream<IO>have the same shapes; swap the import and adjust the config builder - No
spawn_blocking— wolfSSL runs inline in the async task over in-memory buffers; one connection does not consume one OS thread
Usage
[]
= "0.1"
= { = "1", = ["full"] }
TLS client
use Arc;
use TcpStream;
use ;
let mut roots = new;
roots.add_pem;
let config = new;
let stream = connect.await?;
let mut tls = from.connect?.await?;
tls.write_all.await?;
connect() returns Result<Connect<IO>>; the ? checks for config errors and
the .await? drives the handshake to completion.
TLS server
use Arc;
use TcpListener;
use ;
let config = new;
let acceptor = from;
let listener = bind.await?;
loop
Mutual TLS (mTLS)
// Server — require a client certificate
let config = builder
.with_certificate_chain
.with_client_auth
.build?;
// Client — present a certificate
let config = builder
.with_root_certificates
.with_client_auth
.build?;
How it works
wolfssl-src Compiles wolfSSL C source
│
wolfcrypt-sys bindgen FFI bindings
│
wolfcrypt-tls Config types, cert/key loading (lib.name = "wolfssl")
│
wolfcrypt-tls-tokio TlsConnector / TlsAcceptor / TlsStream ← this crate
│
tokio AsyncRead, AsyncWrite, TcpStream
Instead of wolfSSL_set_fd, the crate drives wolfSSL through custom IO
callbacks over two in-memory byte buffers (net_in / net_out):
┌───────────────────────────────────┐
│ TlsStream<IO> │
poll_read ◄───────┤ read_buf (decrypted plaintext) │
poll_write ───────►│ wolfSSL session │
│ recv_cb ◄── net_in │
│ send_cb ──► net_out │
network IO ◄───────┤ flush net_out / fill net_in ─────►│ network IO
(cipher) └───────────────────────────────────┘ (cipher)
The callbacks are synchronous and never block. All real async network I/O
happens in poll_read / poll_write around the wolfSSL calls — the same
architecture as tokio-rustls.
Config types (TlsClientConfig, TlsServerConfig, Certificate,
PrivateKey, RootCertStore, ProtocolVersion) are re-exported from
wolfcrypt-tls. The wolfcrypt-tls-futures-io crate provides the same
session logic for the futures::io trait family (smol, async-std).
| Feature | Description |
|---|---|
vendored |
Compile wolfSSL from source (passes through to wolfcrypt-tls) |
fips |
Enable the wolfSSL FIPS 140-3 code path (commercial license required) |
References
- wolfcrypt-tls — blocking API and config types re-exported here
- wolfcrypt-tls-futures-io —
futures::iovariant of the same session logic - tokio — async runtime providing
AsyncRead/AsyncWriteand theTcpStream/TcpListenertypes used in the examples - tokio-rustls — API model
this crate mirrors (
TlsConnector/TlsAcceptor/TlsStream<IO>) - wolfSSL documentation
- RFC 8446 — TLS 1.3
- RFC 5246 — TLS 1.2
- workspace README
Copyright
Copyright (C) 2006-2026 wolfSSL Inc.
License
GPL-3.0-only OR LicenseRef-wolfSSL-commercial.
The underlying wolfSSL C library is licensed under GPL-3.0-or-later with a commercial option available from wolfSSL Inc.