Source
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
static zbx_get_program_type_f zbx_get_program_type_cb = NULL;
static ZBX_THREAD_LOCAL const char *my_psk_identity = NULL;
static ZBX_THREAD_LOCAL size_t my_psk_identity_len = 0;
static ZBX_THREAD_LOCAL char *my_psk = NULL;
static ZBX_THREAD_LOCAL size_t my_psk_len = 0;
/* Pointer to zbx_dc_get_psk_by_identity() initialized at runtime. This is a workaround for linking. */
/* Server and proxy link with src/libs/zbxdbcache/dbconfig.o where zbx_dc_get_psk_by_identity() resides */
/* but other components (e.g. agent) do not link dbconfig.o. */
static zbx_find_psk_in_cache_f find_psk_in_cache_cb = NULL;
/* variable for passing information from callback functions if PSK was found among host PSKs or autoregistration PSK */
static unsigned int psk_usage;
static zbx_tls_status_t tls_status = ZBX_TLS_INIT_NONE;
static ZBX_THREAD_LOCAL gnutls_certificate_credentials_t my_cert_creds = NULL;
static ZBX_THREAD_LOCAL gnutls_psk_client_credentials_t my_psk_client_creds = NULL;
static ZBX_THREAD_LOCAL gnutls_psk_server_credentials_t my_psk_server_creds = NULL;
static ZBX_THREAD_LOCAL gnutls_priority_t ciphersuites_cert = NULL;
static ZBX_THREAD_LOCAL gnutls_priority_t ciphersuites_psk = NULL;
static ZBX_THREAD_LOCAL gnutls_priority_t ciphersuites_all = NULL;
/******************************************************************************
* *
* Purpose: write a GnuTLS debug message into Zabbix log *
* *
* Comments: *
* This is a callback function, its arguments are defined in GnuTLS. *
* *
******************************************************************************/
static void zbx_gnutls_debug_cb(int level, const char *str)
{
char msg[1024];
/* remove '\n' from the end of debug message */
zbx_strlcpy(msg, str, sizeof(msg));
zbx_rtrim(msg, "\n");