0

Quick question, does reqwest allow self-signed certificates? I have created a tls enabled rust-warp webserver. And I have created a reqwest client to make requests to this server for testing purposes. The cert added to add_root_certificate is the same certificate which the server is using. It's odd because when I use other clients such as Python or CURL there are no issues making the requests, and I do not get a TLS error on my server.

Here's my sample rust code:

let mut buf = Vec::new();
File::open("my_cert.pem")?
.read_to_end(&mut buf)?;
let cert = reqwest::Certificate::from_pem(&buf)?;
let client = reqwest::Client::builder()
.add_root_certificate(cert)
.build()?;

let mut map = HashMap::new();
map.insert("name", "John");

let res = client.post("https://IP:PORT/endpoint).json(&map).send().await?;

And here's my sample Python code:

`

path_to_cert = "path/to/cert/my_cert.pem"
route = "https://IP:PORT/endpoint"
payload = {
"name": "John",
}
res = requests.post(url, data = json.dumps(payload), verify=path_to_cert)

Not sure what is causing this issue? Any help would be greatly appreciated, thank you!

I have built a rust-warp server, and I am posting data to it for testing. I expect my rust-request to successfully post data to my server, but my server logs:

TLS alert received AlertMessagePayload { level: Fatal, description: CertificateUnknown, }

  • Does this answer your question? [How can I accept invalid or self-signed SSL certificates in Rust futures reqwest?](https://stackoverflow.com/questions/65977261/how-can-i-accept-invalid-or-self-signed-ssl-certificates-in-rust-futures-reqwest) – cafce25 Jul 19 '23 at 21:29
  • @cafce25 it seems the answer there resolved an issue unrelated to the title (OP missing `.send()`) and in the comments said the cert issue persisted :/ – kmdreko Jul 20 '23 at 03:04
  • adding .danger_accept_invalid_cert(true) worked. But I am not sure why I need this, because other clients such as CURL and Python requests have no problems making HTTPs requests with the same cert I am adding to reqwest using .add_root_certificate(cert) – Haider Khan Jul 20 '23 at 22:28

0 Answers0