gnutls_certificate_verify_peers2(3)

πŸ’– gnutls_certificate_verify_peers2 πŸ’–

okay bestie, so this page lives in the gnutls manual, and the function we're stanning today is gnutls_certificate_verify_peers2. she's an API function, and she's the one who checks whether the peer's certificate is actually giving trustworthy πŸ’…


✨ NAME ✨

gnutls_certificate_verify_peers2 β€” API function, no cap, that's literally her whole name πŸŽ€


🌸 SYNOPSIS 🌸

#include <gnutls/gnutls.h>

int gnutls_certificate_verify_peers2(gnutls_session_t session, unsigned
int * status);

yes the unsigned and int * status are split across two lines like that, that's just how the header prints it, don't come for me πŸ™ˆ


πŸ¦‹ ARGUMENTS πŸ¦‹

  • gnutls_session_t session β€” is a gnutls session. that's it, that's the whole description, she's a session and she's iconic πŸ‘‘
  • unsigned int * status β€” is the output of the verification. this is where the tea gets stored, so pay attention to it πŸ“

πŸ’œ DESCRIPTION πŸ’œ

so like, 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. zero = trusted = slay ✨

not me needing you to know: the value in status is set only when the return value of this function is success (i.e., failure to trust a certificate does not imply a negative return value). so a happy return code does NOT mean the cert is good. read status. periodt πŸ’€

the default verification flags used by this function can be overridden using gnutls_certificate_set_verify_flags().

this function will take into account the stapled OCSP responses sent by the server, as well as the following X.509 certificate extensions: Name Constraints</>, Key Usage</>, and Basic Constraints</> (pathlen</>). she's thorough, she read the whole assignment πŸ“š

🫢 also you must check the peer's name in order to check if the verified certificate belongs to the actual peer. see gnutls_x509_crt_check_hostname(), or just use gnutls_certificate_verify_peers3(). like, verifying the cert β‰  verifying the hostname, those are two separate vibe checks 😭

to avoid denial of service attacks some default upper limits regarding the certificate key size and chain size are set. to override them use gnutls_certificate_set_verify_limits(). safety first bestie πŸ›‘οΈ

⚠️ and here's the plot twist: when 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. nothing to verify, nothing to slay, it's giving void 🌈

⭐ RETURNS ⭐

GNUTLS_E_SUCCESS (0) when the validation is performed, or a negative error code otherwise. and fr fr: a successful error code means that the status parameter must be checked to obtain the validation status. return code = "did the check even run", status = "did the cert pass". two different questions, don't mix them up πŸ’…


πŸŽ€ REPORTING BUGS πŸŽ€

found a bug? 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. so yes, share her around, just keep the receipts πŸ’–


🌈 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, go forth and verify those peers responsibly πŸ§šπŸ’œ

this was brought to you by the gnutls</> manual, version 3.8.13</> β€” mwah, love u, bye 🫢✨

πŸ“¦ where this page comes from