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§
source§impl 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§
source§impl Clone for AlpnConnector
impl Clone for AlpnConnector
source§fn clone(&self) -> AlpnConnector
fn clone(&self) -> AlpnConnector
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for AlpnConnector
impl Debug for AlpnConnector
source§impl Default for AlpnConnector
impl Default for AlpnConnector
source§impl 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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more