/*++ /* NAME /* tls_verify 3 /* SUMMARY /* peer name and peer certificate verification /* SYNOPSIS /* #define TLS_INTERNAL /* #include <tls.h> /* /* int tls_verify_certificate_callback(ok, ctx) /* int ok; /* X509_STORE_CTX *ctx; /* /* int tls_log_verify_error(TLScontext, tlsrpt) /* TLS_SESS_STATE *TLScontext; /* struct TLSRPT_WRAPPER *tlsrpt; /* /* char *tls_peer_CN(peercert, TLScontext) /* X509 *peercert; /* TLS_SESS_STATE *TLScontext; /* /* char *tls_issuer_CN(peercert, TLScontext) /* X509 *peercert; /* TLS_SESS_STATE *TLScontext; /* DESCRIPTION /* tls_verify_certificate_callback() is called several times (directly /* or indirectly) from crypto/x509/x509_vfy.c. It collects errors /* and trust information at each element of the trust chain. /* The last call at depth 0 sets the verification status based /* on the cumulative winner (lowest depth) of errors vs. trust. /* We always return 1 (continue the handshake) and handle trust /* and peer-name verification problems at the application level. /* /* tls_log_verify_error() (called only when we care about the /* peer certificate, that is not when opportunistic) logs the /* reason why the certificate failed to be verified. /* /* tls_peer_CN() returns the text CommonName for the peer /* certificate subject, or an empty string if no CommonName was /* found. The result is allocated with mymalloc() and must be /* freed by the caller; it contains UTF-8 without non-printable /* ASCII characters. /* /* tls_issuer_CN() returns the text CommonName for the peer /* certificate issuer, or an empty string if no CommonName was /* found. The result is allocated with mymalloc() and must be /* freed by the caller; it contains UTF-8 without non-printable /* ASCII characters. /* /* Arguments: /* .IP ok /* Result of prior verification: non-zero means success. In /* order to reduce the noise level, some tests or error reports /* are disabled when verification failed because of some /* earlier problem. /* .IP ctx /* SSL application context. This links to the Postfix TLScontext /* with enforcement and logging options. /* .IP gn /* An OpenSSL GENERAL_NAME structure holding a DNS subjectAltName /* to be decoded and checked for validity. /* .IP peercert /* Server or client X.509 certificate. /* .IP TLScontext /* Server or client context for warning messages. /* DIAGNOSTICS /* tls_peer_CN() and tls_issuer_CN() log a warning when 1) the requested /* information is not available in the specified certificate, 2) the /* result exceeds a fixed limit, 3) the result contains NUL characters or /* the result contains non-printable or non-ASCII characters. /* LICENSE /* .ad /* .fi /* This software is free. You can do with it whatever you want. /* The original author kindly requests that you acknowledge /* the use of his software. /* AUTHOR(S) /* Originally written by: /* Lutz Jaenicke /* BTU Cottbus /* Allgemeine Elektrotechnik /* Universitaetsplatz 3-4 /* D-03044 Cottbus, Germany /* /* Updated by: /* Wietse Venema /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA /* /* Victor Duchovni /* Morgan Stanley /* /* Wietse Venema /* porcupine.org
/*--*/
/* tls_verify_certificate_callback - verify peer certificate info */
int tls_verify_certificate_callback(int ok, X509_STORE_CTX *ctx)
{ char buf[CCERT_BUFSIZ]; const X509 *cert; int err; int depth;
SSL *con;
TLS_SESS_STATE *TLScontext;
EVP_PKEY *rpk = 0;
/* May be NULL as of OpenSSL 1.0, thanks for the API change! */
cert = X509_STORE_CTX_get_current_cert(ctx);
err = X509_STORE_CTX_get_error(ctx);
con = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
TLScontext = SSL_get_ex_data(con, TLScontext_index);
depth = X509_STORE_CTX_get_error_depth(ctx); #if OPENSSL_VERSION_PREREQ(3,2) if (cert == 0)
rpk = X509_STORE_CTX_get0_rpk(ctx); #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.