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 duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const 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
Auto Trait Implementations§
impl Freeze for AlpnConnector
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