reqwest icon indicating copy to clipboard operation
reqwest copied to clipboard

Get the server's SSL certificate

Open bramp opened this issue 4 years ago • 7 comments

Is it possible to extract the server's certificate chain from a Response? In addition to say SSL/TLS version, and other cipher information?

I looked at using use_preconfigured_tls and passing my own tls client, with a customer ServerCertVerifier but it

  1. Seems unclear how to tie back the specific request to the ServerCertVerifier verification calls (especially if I'm using the client to send many requests), and
  2. Seems to be duplicating a lot of code you already have.

thanks in advance

bramp avatar Jan 08 '22 07:01 bramp

Nope, it's not currently possible. The specific TLS libraries that reqwest uses may provide that information internally, but it'd take some work to collect it and present it on the Response. Even more work if the TLS connectors don't provide that info yet.

seanmonstar avatar Jan 10 '22 17:01 seanmonstar

Would you accept a pull request, if I got this implemented (including in the underlying libraries) and it wasn't horrible, etc?

I suspect I'd create a HttpInfo like extension, that will contain various TLS information.

bramp avatar Jan 10 '22 21:01 bramp

Yes absolutely! I think some of the connectors may already insert an extension, like HttpInfo. But I haven't checked in a while.

seanmonstar avatar Jan 10 '22 22:01 seanmonstar

Ideally, whatever is exposed on the Response is a wrapper type from reqwest::tls, which doesn't expose the underlying TLS type.

seanmonstar avatar Jan 10 '22 22:01 seanmonstar

Hi... This is exactly what I'm looking for... @bramp : Did you make any headway on this ? Thanks JR

JRAndreassen avatar Apr 26 '22 20:04 JRAndreassen

ah sorry, I found a workaround by not using reqwest, so have not made progress, and will likely not make progress in the short term.

bramp avatar Apr 26 '22 21:04 bramp

@bramp, Ahh, yes... "there is a crate for that"... I was hoping to avoid hitting it again... Thanks for letting me know. JR

JRAndreassen avatar Apr 26 '22 22:04 JRAndreassen