#libressl #openbsd

sys libtls-sys

FFI bindings for LibreSSL's libtls

7 releases (stable)

1.2.0 Apr 9, 2020
1.1.2 Dec 20, 2019
1.1.0-alpha1 Nov 11, 2019
0.0.1 May 7, 2016

#1243 in Cryptography

Download history 14/week @ 2023-10-22 54/week @ 2023-10-29 44/week @ 2023-11-05 18/week @ 2023-11-12 17/week @ 2023-11-19 70/week @ 2023-11-26 56/week @ 2023-12-03 30/week @ 2023-12-10 12/week @ 2023-12-17 56/week @ 2023-12-24 13/week @ 2023-12-31 12/week @ 2024-01-07 35/week @ 2024-01-14 31/week @ 2024-01-21 52/week @ 2024-01-28 15/week @ 2024-02-04

135 downloads per month
Used in 2 crates (via libtls)

ISC license

4MB
5.5K SLoC

C 2K SLoC // 0.2% comments Automake 1.5K SLoC // 0.1% comments Shell 1.5K SLoC // 0.1% comments M4 332 SLoC // 0.2% comments Batch 246 SLoC // 0.1% comments Rust 125 SLoC // 0.2% comments Pan 3 SLoC

Rust bindings for LibreSSL's libtls.

Crates.IO docs.rs Actions Build Status License

Documentation, Changelog

The LibreSSL project provides a free TLS and crypto stack that was forked from OpenSSL in 2014. The goals are to provide a modernized codebase, improved security, and to apply best practice development processes.

LibreSSL provides C APIs that are compatible to OpenSSL's libssl and libcrypto libraries. It also provides libtls, a new TLS library that is designed to make it easier to write foolproof applications.

This workspace of Rust crates provides language bindings for libtls only, as the other LibreSSL APIs can be used with the existing rust-openssl crate. LibreSSL versions 2.9.0 through 3.1.0 (or later) are supported. TLSv1.3 requires LibreSSL 3.1.0 or later.

The following crates are included:

Minimum Rust version

Async I/O with tokio-libtls requires Rust 1.39 or later for async-await. This crate does not provide any backwards compatibility but you can use version 1.0.0 on older Rust versions.

Examples

See the examples directory for various examples to configure, establish, and connect synchronous and asynchronous TLS connections. The following selected example creates a non-blocking and asynchronous TLS connection using Tokio and the tokio-libtls crate:

use std::io;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio_libtls::prelude::*;

async fn async_https_connect(servername: &str) -> io::Result<()> {
    let addr = &(servername.to_owned() + ":443");

    let request = format!(
        "GET / HTTP/1.1\r\n\
         Host: {}\r\n\
         Connection: close\r\n\r\n",
        servername
    );

    let config = Builder::new().build()?;
    let mut tls = connect(addr, &config, None).await?;
    tls.write_all(request.as_bytes()).await?;

    let mut buf = vec![0u8; 1024];
    tls.read_exact(&mut buf).await?;

    let ok = b"HTTP/1.1 200 OK\r\n";
    assert_eq!(&buf[..ok.len()], ok);

    Ok(())
}

#[tokio::main]
async fn main() {
    async_https_connect("www.example.com").await.unwrap();
}

Licensed under an OpenBSD-ISC-style license, see LICENSE for details.

Dependencies