I'm trying to use Reqwest's proxy feature to pass user:pass basic auth with the rest of the URL into the proxy function. Apparently, the way this crate works basic auth can't be passed this way for the proxy.
When I commented out proxy I got my data but it didn't go through my proxy:
let raw_proxy = format!("https://{}:{}@{}", username, password, forward_proxy);
let proxy = reqwest::Proxy::all(&raw_proxy).unwrap();
let mut buf = &mut Vec::new();
File::open("../cert.der").unwrap().read_to_end(&mut buf).unwrap();
let cert = reqwest::Certificate::from_der(&buf).unwrap();
let client = reqwest::Client::builder()
.add_root_certificate(cert)
//.proxy(proxy)
.build().unwrap();
let mut res = client.post("http://httpbin.org/post")
.header(ContentType::json())
.body(format!("{}", redacted_data))
.send().unwrap();
Short answer is you cannot without writing more code. For the longer answer see this ticket I opened 2 years back. https://github.com/hyperium/hyper/issues/531
Basically, authenticated proxies do not work currently. The headers are not being updated.
The author is supportive, it is just not a high priority. I stopped being behind a proxy so it stopped being one for me too.