func NewClient(nc net.Conn, cfg *Config, timeout time.Duration, shiftDeadline bool, address string) (conn net.Conn, err error) {
** 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/>.
#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 golang.zabbix.com/agent2/pkg/tls cannot be compiled with LibreSSL. Encryption is supported with OpenSSL.
#elif !defined(HAVE_OPENSSL_WITH_PSK)
# error package golang.zabbix.com/agent2/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 golang.zabbix.com/agent2/pkg/tls requires OpenSSL 1.1.1 or newer.
#elif OPENSSL_VERSION_NUMBER < 0x1000100fL
# error package golang.zabbix.com/agent2/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
# define SSL_CTX_set_min_proto_version(ctx, TLSv) 1
#define TLS_EX_DATA_ERRBIO 0
#define TLS_EX_DATA_IDENTITY 1