Struct hyper_alpn::AlpnConnector[][src]

pub struct AlpnConnector { /* fields omitted */ }

Connector for Application-Layer Protocol Negotiation to form a TLS connection for Hyper.

Methods

impl AlpnConnector
[src]

Construct a new AlpnConnector.

Construct a new AlpnConnector with a custom certificate and private key, which should be in PEM format.

extern crate openssl;
extern crate hyper;
extern crate hyper_alpn;
extern crate futures;
extern crate tokio;

use futures::{future, Future};
use hyper_alpn::AlpnConnector;
use hyper::Client;
use openssl::pkcs12::Pkcs12;
use std::{fs::File, io::Read};

fn main() {
    let mut certificate = File::open("path/to/cert.p12").unwrap();
    let mut der: Vec<u8> = Vec::new();
    certificate.read_to_end(&mut der).unwrap();

    let pkcs = Pkcs12::from_der(&der)
        .unwrap()
        .parse("my_p12_password")
        .unwrap();

    let connector = AlpnConnector::with_client_cert(
        &pkcs.cert.to_pem().unwrap(),
        &pkcs.pkey.private_key_to_pem_pkcs8().unwrap(),
    ).unwrap();

    let mut builder = Client::builder();
    builder.http2_only(true);

    let client: Client<AlpnConnector> = builder.build(connector);
}

Trait Implementations

impl Debug for AlpnConnector
[src]

Formats the value using the given formatter. Read more

impl Connect for AlpnConnector
[src]

The connected IO Stream.

An error occured when trying to connect.

A Future that will resolve to the connected Transport.

Connect to a destination.

Auto Trait Implementations