gnutls_certificate_verify_peers(3)

✨ NAME ✨

gnutls_certificate_verify_peers β€” literally just an API function bestie, and this whole page lives in the gnutls manual πŸ’–


🌸 SYNOPSIS 🌸

#include <gnutls/gnutls.h>

int gnutls_certificate_verify_peers(gnutls_session_t session,
gnutls_typed_vdata_st * data, unsigned int elements, unsigned int *
status);

πŸŽ€ ARGUMENTS πŸŽ€

  • gnutls_session_t session β€” okay so this one is a gnutls session, that's it, that's the vibe 🫢
  • gnutls_typed_vdata_st * data β€” an array of typed data, slay
  • unsigned int elements β€” the number of data elements in that array, count them bestie
  • unsigned int * status β€” this is where the output of the verification goes πŸ‘‘

πŸ’… DESCRIPTION πŸ’…

So this function will verify the peer's certificate and store the status in the status variable as a bitwise OR of gnutls_certificate_status_t values, or zero if the certificate is trusted. ✨

Important glow-up note: the value in status is only set when the return value of this function is success. That means failure to trust a certificate does not imply a negative return value β€” so don't go assuming a happy return code means the cert is trusted, because it absolutely does not, no cap 😭

The default verification flags this function uses can be overridden with gnutls_certificate_set_verify_flags(). And for the details on the verification process itself, see the documentation of gnutls_certificate_verify_peers2(). πŸ“š

This function will take into account the stapled OCSP responses sent by the server, plus these X.509 certificate extensions: Name Constraints, Key Usage, and Basic Constraints (pathlen). πŸ¦‹

The acceptable data types are GNUTLS_DT_DNS_HOSTNAME, GNUTLS_DT_RFC822NAME and GNUTLS_DT_KEY_PURPOSE_OID. The former two accept as data a null-terminated hostname or email address, and the latter takes a null-terminated object identifier (e.g., GNUTLS_KP_TLS_WWW_SERVER). πŸ“

If a DNS hostname is provided then this function will compare the hostname in the certificate against the given one. If the names do not match, the GNUTLS_CERT_UNEXPECTED_OWNER status flag gets set. 🚩 If a key purpose OID is provided and the end-certificate contains the extended key usage PKIX extension, it will be required to have the provided key purpose or be marked for any purpose β€” otherwise the verification status will have the GNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE flag set. πŸ’€

To avoid denial of service attacks, some default upper limits regarding the certificate key size and chain size are set. Wanna override them? Use gnutls_certificate_set_verify_limits(). πŸ›‘οΈ

Big heads-up: when you're using raw public-keys, verification will not work, because there is no corresponding certificate body belonging to the raw key that can be verified. In that case this function will return GNUTLS_E_INVALID_REQUEST. Periodt. 🚫

🌈 RETURNS 🌈

GNUTLS_E_SUCCESS (0) when the validation is performed, or a negative error code otherwise. A successful error code means that the status parameter must be checked to obtain the validation status β€” yes, both things, check them both bestie, iykyk 😌


⭐ SINCE ⭐

3.3.0 β€” she's been iconic for a minute πŸ’œ


πŸ™ˆ REPORTING BUGS πŸ™ˆ

Report bugs to <bugs@gnutls.org>.

Home page: https://www.gnutls.org


Copyright Β© 2001-2023 Free Software Foundation, Inc., and others.

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. πŸŽ€


🧚 SEE ALSO 🧚

The full documentation for gnutls is maintained as a Texinfo manual. If the /usr/share/doc/gnutls/ directory does not contain the HTML form, visit

https://www.gnutls.org/manual/

okay that's the whole page, you ate that πŸ’… this was gnutls version 3.8.13, from the gnutls manual, and yes the source line said exactly that β€” mwah, go verify some peers responsibly bestie πŸ¦‹βœ¨

πŸ“¦ where this page comes from