| Crates.io | openssl-ktls |
| lib.rs | openssl-ktls |
| version | 0.2.3 |
| created_at | 2025-08-01 04:42:37.609349+00 |
| updated_at | 2025-08-11 04:49:25.643623+00 |
| description | Openssl KTLS support (with tokio) |
| homepage | |
| repository | https://github.com/youyuanwu/rust-openssl-ktls |
| max_upload_size | |
| id | 1776100 |
| size | 41,665 |
Use openssl with kernel TLS offload, optionally with tokio.
This crate implements sync SslStream and async tokio SslStream that are ktls capable, extending the openssl crate.
Add to Cargo.toml
openssl-ktls = { version = "*", default-features = false, features = ["tokio", "vendored"]}
tokio enables tokio based async SslStream.vendored enableds build openssl from source with ktls enabled. If your system openssl is already built with ktls enabled, you can skip this feature.SslStream works the same way as openssl::ssl::SslStream.
let mut connector =
openssl::ssl::SslConnector::builder(openssl::ssl::SslMethod::tls()).unwrap();
let connector = connector.set_options(openssl_ktls::option::SSL_OP_ENABLE_KTLS)
.set_cipher_list(openssl_ktls::option::ECDHE_RSA_AES128_GCM_SHA256).unwrap()
.configure().unwrap();
let ssl = connector.into_ssl("localhost").unwrap();
let tcp_stream = tokio::net::TcpStream::connect("localhost:8080").await.unwrap();
let mut ssl_stream = openssl_ktls::TokioSslStream::new(tcp_stream, ssl).unwrap();
// read and write data on ssl_stream...
// check ktls is used.
let receive_enabled = ssl_s.ktls_recv_enabled();
let send_enabled = ssl_s.ktls_send_enabled();
This project is licensed under the MIT license.