MCPcopy Create free account
hub / github.com/actix/examples / route_whoami

Function route_whoami

https-tls/rustls-client-cert/src/main.rs:30–39  ·  view source on GitHub ↗
(req: HttpRequest)

Source from the content-addressed store, hash-verified

28}
29
30async fn route_whoami(req: HttpRequest) -> impl Responder {
31 let conn_info = req.conn_data::<ConnectionInfo>().unwrap();
32 let client_cert = req.conn_data::<CertificateDer<'static>>();
33
34 if let Some(cert) = client_cert {
35 HttpResponse::Ok().body(format!("{:?}\n\n{:?}", conn_info, cert))
36 } else {
37 HttpResponse::Unauthorized().body("No client certificate provided.")
38 }
39}
40
41fn get_client_cert(connection: &dyn Any, data: &mut Extensions) {
42 if let Some(tls_socket) = connection.downcast_ref::<TlsStream<TcpStream>>() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected