I need my app to have access to the tls cert used by the client. The only "possible" way was generated by AI but is no longer valid on newer versions of axum_server as tls backend has switched to rustls or openssl:
// Handler to extract client TLS info
async fn client_tls_info(req: Request<axum::body::Body>) -> String {
// Extract TLS information from request extensions
if let Some(tls_connection) = req.extensions().get::<axum_server::tls::TlsConnection>() {
// Extract client certificate information
let client_certificates = tls_connection.peer_certificates();
if let Some(certificates) = client_certificates {
// Extract some details about the client certificate
let cert_info: Vec<String> = certificates
.iter()
.map(|cert| format!("Subject: {}", cert.subject()))
.collect();
return format!("Client certificates: {:?}", cert_info);
}
}
"No client certificates found".to_string()
}
axum_server::tls no longer exists. Is this feature no longer possible?
I need my app to have access to the tls cert used by the client. The only "possible" way was generated by AI but is no longer valid on newer versions of axum_server as tls backend has switched to rustls or openssl:
axum_server::tls no longer exists. Is this feature no longer possible?