Struct hyper_alpn::AlpnConnector
source · [−]pub struct AlpnConnector { /* private fields */ }Expand description
Connector for Application-Layer Protocol Negotiation to form a TLS connection for Hyper.
Implementations
sourceimpl AlpnConnector
impl AlpnConnector
sourcepub fn with_client_cert(cert_pem: &[u8], key_pem: &[u8]) -> Result<Self, Error>
pub fn with_client_cert(cert_pem: &[u8], key_pem: &[u8]) -> Result<Self, Error>
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 tokio;
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
sourceimpl Clone for AlpnConnector
impl Clone for AlpnConnector
sourcefn clone(&self) -> AlpnConnector
fn clone(&self) -> AlpnConnector
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for AlpnConnector
impl Debug for AlpnConnector
sourceimpl Default for AlpnConnector
impl Default for AlpnConnector
sourceimpl Service<Uri> for AlpnConnector
impl Service<Uri> for AlpnConnector
type Response = AlpnStream
type Response = AlpnStream
Responses given by the service.
type Future = AlpnConnecting
type Future = AlpnConnecting
The future response value.
Auto Trait Implementations
impl !RefUnwindSafe for AlpnConnector
impl Send for AlpnConnector
impl Sync for AlpnConnector
impl Unpin for AlpnConnector
impl !UnwindSafe for AlpnConnector
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more