func NewClient(nc net.Conn, cfg *Config, timeout time.Duration, shiftDeadline bool, address string) (conn net.Conn, err error) {
** Copyright (C) 2001-2023 Zabbix SIA
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
** 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 General Public License for more details.
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#cgo CFLAGS: -I${SRCDIR}/../../../../include -I${SRCDIR}/../../../../build/win32/include
#cgo openssl LDFLAGS: -lssl -lcrypto -lwsock32 -lws2_32
#include "common/config.h"
#define TLS_UNUSED(var) (void)(var)
const char *tls_crypto_init_msg;
#include <openssl/rand.h>
#if defined(LIBRESSL_VERSION_NUMBER)
# error package zabbix.com/pkg/tls cannot be compiled with LibreSSL. Encryption is supported with OpenSSL.
#elif !defined(HAVE_OPENSSL_WITH_PSK)
# error package zabbix.com/pkg/tls cannot be compiled with OpenSSL which has excluded PSK support.
#elif defined(_WINDOWS) && OPENSSL_VERSION_NUMBER < 0x1010100fL // On MS Windows OpenSSL 1.1.1 is required
# error on Microsoft Windows the package zabbix.com/pkg/tls requires OpenSSL 1.1.1 or newer.
#elif OPENSSL_VERSION_NUMBER < 0x1000100fL
# error package zabbix.com/pkg/tls cannot be compiled with this OpenSSL version.\
Supported versions are 1.0.1 and newer.
#if OPENSSL_VERSION_NUMBER < 0x1010000fL
// OpenSSL 1.0.1/1.0.2 (before 1.1.0)
#include <openssl/x509v3.h> // string_to_hex()
# define OPENSSL_hexstr2buf string_to_hex
# define TLS_method TLSv1_2_method
# define SSL_CTX_get_ciphers(ciphers) ((ciphers)->cipher_list)
# define OPENSSL_VERSION SSLEAY_VERSION
# define OpenSSL_version SSLeay_version