Struct hyper_alpn::AlpnConnector[][src]

pub struct AlpnConnector { /* fields omitted */ }

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

Implementations

impl AlpnConnector[src]

pub fn new() -> Self[src]

Construct a new AlpnConnector.

pub fn with_client_cert(cert_pem: &[u8], key_pem: &[u8]) -> Result<Self, Error>[src]

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 Clone for AlpnConnector[src]

impl Debug for AlpnConnector[src]

impl Service<Uri> for AlpnConnector[src]

type Response = AlpnStream

Responses given by the service.

type Error = Error

Errors produced by the service.

type Future = AlpnConnecting

The future response value.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.