tls-api-openssl 0.12.1

TLS API implementation over openssl crate
Documentation
#[cfg(feature = "runtime-async-std")]
use async_std::net::TcpStream;
use std::fs;
use test_cert_gen::Cert;
use tls_api::TlsConnector;
use tls_api::TlsConnectorBuilder;
#[cfg(feature = "runtime-tokio")]
use tokio::net::TcpStream;

async fn run() {
    let socket = TcpStream::connect(("127.0.0.1", 4433)).await.unwrap();

    let mut builder = tls_api_openssl::TlsConnector::builder().unwrap();
    builder
        .add_root_certificate(Cert::from_der(fs::read("ca.der").unwrap()).get_der())
        .unwrap();
    let connector = builder.build().unwrap();
    connector.connect("localhost", socket).await.unwrap();
}

#[cfg(feature = "runtime-tokio")]
#[tokio::main]
async fn main() {
    run().await;
}

#[cfg(feature = "runtime-async-std")]
#[async_std::main]
async fn main() {
    run().await;
}