-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Andrey edited this page Oct 5, 2022
·
3 revisions
Welcome to the fl-url wiki!
[dependencies]
flurl = { git="https://github.com/MyJetTools/fl-url.git", tag = "0.2.3", features=["with-client-cert"] }
use std::{fs::File, io::Read};
use native_tls::Identity;
use crate::FlUrl;
let mut cert_file = File::open("/Users/user/Downloads/client-cert.pfx").unwrap();
let mut cert_content = Vec::new();
let load_size = cert_file.read_to_end(&mut cert_content).unwrap();
println!("Cert size is {} bytes", cert_content.len());
let certificate =
Identity::from_pkcs12(cert_content.as_slice(), "password").unwrap();
let mut fl_url = FlUrl::new("https://website-under-client-certificate.com/")
.with_client_certificate(certificate)
.get()
.await
.unwrap();
println!("Result: {}", fl_url.get_status_code());
let result = fl_url.get_body().await.unwrap();
println!("Result: {}", std::str::from_utf8(&result).unwrap());