chttpserver · Section 3
chttpsvr_req_peer_cert_verified
NAME
chttpsvr_req_peer_cert_verified - report whether the TLS client presented a verified certificate
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/chttpserver.h> bool chttpsvr_req_peer_cert_verified(const chttpsvr_req *req);
DESCRIPTION
Returns true only when three things hold: The request arrived over TLS, the client presented a certificate in the handshake, and that certificate verified against the ca_bundle_path of the server. The result is false for a plaintext connection, for a server without a ca_bundle_path, for a client that presented no certificate, and for a NULL req. In the default configuration a server with a ca_bundle_path accepts no client that lacks such a certificate, so there every request reports true. With client_cert_optional set in chttp_tls_config a client that presents nothing is accepted too, and a handler or a middleware uses this function to tell that client apart from a verified one. In both modes a client whose certificate fails to verify never reaches a handler. The answer is a property of the connection. Every request on one keep-alive connection reports the same value, and a resumed TLS session reports the answer of the handshake that set it up.
RETURN VALUE
true or false, as described above.
SEE ALSO
chttpsvr_start(3), chttpsvr_req_peer_cert_der(3), chttpsvr_req_peer_cert_sha256(3), chttpsvr_req_peer_cert_subject(3), CHTTP_TLS_DEFAULT(3)