/*++ /* NAME /* tls_misc 3 /* SUMMARY /* miscellaneous TLS support routines /* SYNOPSIS /* Public functions /* #include <tls.h> /* /* void tls_log_summary(role, usage, TLScontext) /* TLS_ROLE role; /* TLS_USAGE usage; /* TLS_SESS_STATE *TLScontext; /* /* const char *tls_compile_version(void) /* /* const char *tls_run_version(void) /* /* const char **tls_pkey_algorithms(void) /* /* void tls_pre_jail_init(TLS_ROLE) /* TLS_ROLE role; /* /* Internal functions /* #define TLS_INTERNAL /* #include <tls.h> /* /* char *var_tls_cnf_file; /* char *var_tls_cnf_name; /* char *var_tls_high_clist; /* char *var_tls_medium_clist; /* char *var_tls_null_clist; /* char *var_tls_eecdh_auto; /* char *var_tls_eecdh_strong; /* char *var_tls_eecdh_ultra; /* char *var_tls_ffdhe_auto; /* char *var_tls_dane_digests; /* int var_tls_daemon_rand_bytes; /* bool var_tls_append_def_CA; /* bool var_tls_preempt_clist; /* bool var_tls_multi_wildcard; /* char *var_tls_mgr_service; /* char *var_tls_tkt_cipher; /* char *var_openssl_path; /* char *var_tls_server_sni_maps; /* bool var_tls_fast_shutdown; /* /* TLS_APPL_STATE *tls_alloc_app_context(ssl_ctx, log_mask) /* SSL_CTX *ssl_ctx; /* int log_mask; /* /* void tls_free_app_context(app_ctx) /* void *app_ctx; /* /* TLS_SESS_STATE *tls_alloc_sess_context(log_mask, namaddr) /* int log_mask; /* const char *namaddr; /* /* void tls_free_context(TLScontext) /* TLS_SESS_STATE *TLScontext; /* /* void tls_check_version() /* /* long tls_bug_bits() /* /* void tls_param_init() /* /* int tls_library_init(void) /* /* int tls_proto_mask_lims(plist, floor, ceiling) /* const char *plist; /* int *floor; /* int *ceiling; /* /* int tls_cipher_grade(name) /* const char *name; /* /* const char *str_tls_cipher_grade(grade) /* int grade; /* /* const char *tls_set_ciphers(TLScontext, grade, exclusions) /* TLS_SESS_STATE *TLScontext; /* int grade; /* const char *exclusions; /* /* void tls_get_signature_params(TLScontext) /* TLS_SESS_STATE *TLScontext; /* /* void tls_print_errors() /* /* void tls_info_callback(ssl, where, ret)
/* const SSL *ssl; /* unused */ /* int where; /* int ret; /* /* long tls_bio_dump_cb(bio, cmd, argp, len, argi, argl, ret, processed) /* BIO *bio; /* int cmd; /* const char *argp; /* size_t len; /* int argi;
/* long argl; /* unused */ /* int ret; /* size_t *processed; /* /* int tls_log_mask(log_param, log_level) /* const char *log_param; /* const char *log_level; /* /* void tls_update_app_logmask(app_ctx, log_mask) /* TLS_APPL_STATE *app_ctx; /* int log_mask; /* /* const EVP_MD *tls_validate_digest(dgst) /* const char *dgst; /* /* void tls_enable_client_rpk(ctx, ssl) /* SSL_CTX *ctx; /* SSL *ssl; /* /* void tls_enable_server_rpk(ctx, ssl) /* SSL_CTX *ctx; /* SSL *ssl; /* DESCRIPTION /* This module implements public and internal routines that /* support the TLS client and server. /* /* tls_log_summary() logs a summary of a completed TLS connection. /* The "role" argument must be TLS_ROLE_CLIENT for outgoing client /* connections, or TLS_ROLE_SERVER for incoming server connections, /* and the "usage" must be TLS_USAGE_NEW or TLS_USAGE_USED. /* /* tls_compile_version() returns a text string description of /* the compile-time TLS library. /* /* tls_run_version() is just tls_compile_version() but with the runtime /* version instead of the compile-time version. /* /* tls_pkey_algorithms() returns a pointer to null-terminated /* array of string constants with the names of the supported /* public-key algorithms. /* /* tls_alloc_app_context() creates an application context that /* holds the SSL context for the application and related cached state. /* /* tls_free_app_context() deallocates the application context and its /* contents (the application context is stored outside the TLS library). /* /* tls_alloc_sess_context() creates an initialized TLS session context /* structure with the specified log mask and peer name[addr]. /* /* tls_free_context() destroys a TLScontext structure /* together with OpenSSL structures that are attached to it. /* /* tls_check_version() logs a warning when the run-time OpenSSL /* library differs in its major, minor or micro number from /* the compile-time OpenSSL headers. /* /* tls_bug_bits() returns the bug compatibility mask appropriate /* for the run-time library. Some of the bug work-arounds are /* not appropriate for some library versions. /* /* tls_param_init() loads main.cf parameters used internally in /* TLS library. Any errors are fatal. /* /* tls_library_init() initializes the OpenSSL library, optionally /* loading an OpenSSL configuration file. /* /* tls_pre_jail_init() opens any tables that need to be opened before /* entering a chroot jail. The "role" parameter must be TLS_ROLE_CLIENT /* for clients and TLS_ROLE_SERVER for servers. Any errors are fatal. /* /* tls_proto_mask_lims() returns a bitmask of excluded protocols, and /* and the protocol version floor/ceiling, given a list (plist) of /* protocols to include or (preceded by a '!') exclude, or constraints /* of the form '>=name', '<=name', '>=hexvalue', '<=hexvalue'. If "plist" /* contains invalid protocol names, TLS_PROTOCOL_INVALID is returned and /* no warning is logged. /* /* tls_cipher_grade() converts a case-insensitive cipher grade name (high, /* medium, null) to the corresponding TLS_CIPHER_ constant. When the /* input specifies an unrecognized grade, tls_cipher_grade() logs no /* warning, and returns TLS_CIPHER_NONE. /* /* str_tls_cipher_grade() converts a cipher grade to a name. /* When the input specifies an undefined grade, str_tls_cipher_grade() /* logs no warning, returns a null pointer. /* /* tls_set_ciphers() applies the requested cipher grade and exclusions /* to the provided TLS session context, returning the resulting cipher /* list string. The return value is the cipherlist used and is /* overwritten upon each call. When the input is invalid, /* tls_set_ciphers() logs a warning, and returns a null result. /* /* tls_get_signature_params() updates the "TLScontext" with handshake /* signature parameters pertaining to TLS 1.3, where the ciphersuite /* no longer describes the asymmetric algorithms employed in the /* handshake, which are negotiated separately. This function /* has no effect for TLS 1.2 and earlier. /* /* tls_print_errors() queries the OpenSSL error stack, /* logs the error messages, and clears the error stack. /* /* tls_info_callback() is a call-back routine for the /* SSL_CTX_set_info_callback() routine. It logs SSL events /* to the Postfix logfile. /* /* tls_bio_dump_cb() is a call-back routine for the /* BIO_set_callback() routine. It logs SSL content to the /* Postfix logfile. /* /* tls_log_mask() converts a TLS log_level value from string /* to mask. The main.cf parameter name is passed along for /* diagnostics. /* /* tls_update_app_logmask() changes the log mask of the /* application TLS context to the new setting. /* /* tls_validate_digest() returns a static handle for the named /* digest algorithm, or NULL on error. /* /* tls_enable_client_rpk() enables the use of raw public keys in the /* client to server direction, if supported by the OpenSSL library. /* /* tls_enable_server_rpk() enables the use of raw public keys in the /* server to client direction, if supported by the OpenSSL library. /* 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 /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA
/*--*/
/* SNI is silently ignored when we don't care or is NULL or empty */ if (!sni_ctx || !tls_server_sni_maps || !sni || !*sni) return SSL_TLSEXT_ERR_NOACK;
if (!valid_hostname(sni, DONT_GRIPE)) {
msg_warn("TLS SNI from %s is invalid: %s",
TLScontext->namaddr, sni); return SSL_TLSEXT_ERR_NOACK;
}
/* *WithTLS1.3,whentheclient'sproposedkeyshareisnotsupportedby *theserver,theservermayissueaHelloRetryRequest(HRR),andthe *clientwillthenretrywithanewkeyshareonacurvesupportedby *theserver.ThisresultsintheSNIcallbackrunningtwiceforthe *sameconnection. * *Whenthathappens,TheclientMUSTsendtheessentiallythesamehello *message,includingtheSNIname,andsincewe'vealreadyloadedour *certificatechain,wedon'tneedtodoitagain!Therefore,ifwe've *alreadyrecordedthepeerSNIname,justcheckthatithasnot *changed,andreturnsuccess.
*/ if (TLScontext->peer_sni) { if (strcmp(sni, TLScontext->peer_sni) == 0) return SSL_TLSEXT_ERR_OK;
msg_warn("TLS SNI changed from %s initially %s, %s after hello retry",
TLScontext->namaddr, TLScontext->peer_sni, sni); return SSL_TLSEXT_ERR_NOACK;
} do { /* Don't silently skip maps opened with the wrong flags. */
pem = maps_file_find(tls_server_sni_maps, cp, 0);
} while (!pem
&& !tls_server_sni_maps->error
&& (cp = strchr(cp + 1, '.')) != 0);
if (!pem) { if (tls_server_sni_maps->error) {
msg_warn("%s: %s map lookup problem",
tls_server_sni_maps->title, sni);
*alert = SSL_AD_INTERNAL_ERROR; return SSL_TLSEXT_ERR_ALERT_FATAL;
}
msg_info("TLS SNI %s from %s not matched, using default chain",
sni, TLScontext->namaddr);
case EVP_PKEY_DH:
kex_name = "DHE";
TLScontext->kex_bits = EVP_PKEY_bits(dh_pkey); break;
#ifndef OPENSSL_NO_EC case EVP_PKEY_EC:
kex_name = "ECDHE";
kex_curve = ec_curve_name(dh_pkey); break; #endif
}
} if (kex_name) {
TLScontext->kex_name = mystrdup(kex_name);
TLScontext->kex_curve = kex_curve;
} /* Not a problem if NULL */
EVP_PKEY_free(dh_pkey);
/* Resumption makes no use of signature keys or digests */ if (TLScontext->session_reused) return;
/* *Ontheclientend,thecertificatemaybepresent,butnotused,sowe *checkviaSSL_get_signature_nid().Thismeansthatlocalsignature *dataonclientsrequiresatleast1.1.1a.
*/ if (srvr || SSL_get_signature_nid(ssl, &nid)) {
local_pkey = SSL_get_privatekey(ssl);
} /* Signature algorithms for the local end of the connection */ if (local_pkey) { #if OPENSSL_VERSION_PREREQ(3,2) if (srvr)
TLScontext->stoc_rpk = TLSEXT_cert_type_rpk ==
SSL_get_negotiated_server_cert_type(ssl); else
TLScontext->ctos_rpk = TLSEXT_cert_type_rpk ==
SSL_get_negotiated_client_cert_type(ssl); #endif
/* Signature algorithms for the peer end of the connection */ if (peer_pkey != 0) { #if OPENSSL_VERSION_PREREQ(3,2) if (srvr)
TLScontext->ctos_rpk = TLSEXT_cert_type_rpk ==
SSL_get_negotiated_client_cert_type(ssl); else
TLScontext->stoc_rpk = TLSEXT_cert_type_rpk ==
SSL_get_negotiated_server_cert_type(ssl); #endif
/* *FreetheSSLstructureandtheBIOs.Warning:theinternal_biois *connectedtotheSSLstructureandisautomaticallyfreedwithit.Do *notfreeitagain(coredump)!!Onlyfreethenetwork_bio.
*/ if (TLScontext->con != 0)
SSL_free(TLScontext->con);
if (TLScontext->namaddr)
myfree(TLScontext->namaddr); if (TLScontext->serverid)
myfree(TLScontext->serverid);
if (TLScontext->peer_CN)
myfree(TLScontext->peer_CN); if (TLScontext->issuer_CN)
myfree(TLScontext->issuer_CN); if (TLScontext->peer_sni)
myfree(TLScontext->peer_sni); if (TLScontext->peer_cert_fprint)
myfree(TLScontext->peer_cert_fprint); if (TLScontext->peer_pkey_fprint)
myfree(TLScontext->peer_pkey_fprint); if (TLScontext->kex_name)
myfree((void *) TLScontext->kex_name); if (TLScontext->kex_curve)
myfree((void *) TLScontext->kex_curve); if (TLScontext->clnt_sig_name)
myfree((void *) TLScontext->clnt_sig_name); if (TLScontext->clnt_sig_curve)
myfree((void *) TLScontext->clnt_sig_curve); if (TLScontext->clnt_sig_dgst)
myfree((void *) TLScontext->clnt_sig_dgst); if (TLScontext->srvr_sig_name)
myfree((void *) TLScontext->srvr_sig_name); if (TLScontext->srvr_sig_curve)
myfree((void *) TLScontext->srvr_sig_curve); if (TLScontext->srvr_sig_dgst)
myfree((void *) TLScontext->srvr_sig_dgst); if (TLScontext->errorcert)
X509_free((X509 *) TLScontext->errorcert); if (TLScontext->ffail_type)
myfree(TLScontext->ffail_type);
myfree((void *) TLScontext);
}
/* tls_version_split - Split OpenSSL version number into major, minor, ... */
if ((ctx && !SSL_CTX_set1_client_cert_type(ctx, cert_types_rpk, sizeof(cert_types_rpk))) ||
(ssl && !SSL_set1_client_cert_type(ssl, cert_types_rpk, sizeof(cert_types_rpk)))) { if (warned++) {
ERR_clear_error(); return;
}
msg_warn("Failed to enable client to server raw public key support");
tls_print_errors();
} #endif
}
if ((ctx && !SSL_CTX_set1_server_cert_type(ctx, cert_types_rpk, sizeof(cert_types_rpk))) ||
(ssl && !SSL_set1_server_cert_type(ssl, cert_types_rpk, sizeof(cert_types_rpk)))) { if (warned++) {
ERR_clear_error(); return;
}
msg_warn("Failed to enable server to client raw public key support");
tls_print_errors();
} #endif
}
#else
/* *Brokenlinkerworkaround.
*/ int tls_dummy_for_broken_linkers;
#endif
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.27 Sekunden
(vorverarbeitet am 2026-08-09)
¤
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.