Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
86 andreas 1
/*
2
 * Copyright (C) 2022 by Andreas Theofilu <andreas@theosys.at>
3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
 
88 andreas 19
#include <chrono>
20
#include <thread>
21
 
86 andreas 22
#include "tsocket.h"
23
#include "terror.h"
24
#include "tconfig.h"
89 andreas 25
#include "texcept.h"
86 andreas 26
 
27
#include <string.h>
28
#include <strings.h>
29
#include <sys/socket.h>
30
#include <sys/types.h>
31
#include <unistd.h>
32
#include <stdlib.h>
33
#include <fcntl.h>
34
#include <netinet/in.h>
35
#include <netdb.h>
36
#include <netinet/tcp.h>
37
#include <openssl/err.h>
38
#include <sys/socket.h>
39
#include <arpa/inet.h>
40
#include <signal.h>
41
#include <poll.h>
42
 
43
using std::string;
44
 
45
int _cert_callback(int preverify_ok, X509_STORE_CTX *ctx);
46
 
92 andreas 47
TSocket::TSocket()
48
{
49
    DECL_TRACER("TSocket::TSocket()")
50
}
51
 
86 andreas 52
TSocket::TSocket(const string& host, int port)
53
{
92 andreas 54
    DECL_TRACER("TSocket::TSocket(const std::string& host, int port)");
86 andreas 55
 
56
    mHost = host;
57
    mPort = port;
58
}
59
 
60
TSocket::~TSocket()
61
{
62
    DECL_TRACER("TSocket::~TSocket()");
63
 
64
    close();
65
}
66
 
67
 
68
bool TSocket::connect(bool encrypt)
69
{
88 andreas 70
    DECL_TRACER("TSocket::connect(bool encrypt)");
86 andreas 71
 
72
    struct addrinfo *ainfo = nullptr;
73
    int sock = -1;
74
    int on = 1;
75
    bool retry = true;
76
 
93 andreas 77
    MSG_INFO("Trying to connect to host " << mHost << " at port " << mPort);
86 andreas 78
 
79
    if ((ainfo = lookup_host(mHost, mPort)) == nullptr)
80
        return false;
81
 
82
    while (ainfo && retry)
83
    {
84
        sock = socket(ainfo->ai_family, ainfo->ai_socktype, ainfo->ai_protocol);
85
 
86
        if (sock == -1)
87
        {
93 andreas 88
            MSG_ERROR("[" << mHost << "] Error opening socket: " << strerror(errno));
86 andreas 89
            ainfo = ainfo->ai_next;
90
            continue;
91
        }
92
 
93 andreas 93
        MSG_DEBUG("[" << mHost << "] Socket successfully created.");
86 andreas 94
        struct in_addr  *addr;
95
 
96
        if (ainfo->ai_family == AF_INET)
97
        {
98
            struct sockaddr_in *ipv = (struct sockaddr_in *)ainfo->ai_addr;
99
            addr = &(ipv->sin_addr);
100
        }
101
        else
102
        {
103
            struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)ainfo->ai_addr;
104
            addr = (struct in_addr *) &(ipv6->sin6_addr);
105
        }
106
 
107
        char buffer[100];
88 andreas 108
        // FIXME: This is the address where we connected to, but we need the
109
        //        address of the local network interface where the connection
110
        //        was initiated from.
86 andreas 111
        inet_ntop(ainfo->ai_family, addr, buffer, sizeof(buffer));
112
        mMyIP.assign(buffer);
88 andreas 113
        MSG_DEBUG("Client IP: " << mMyIP);
86 andreas 114
 
115
        struct timeval tv;
116
 
117
        // FIXME: Make the timeouts configurable!
118
        tv.tv_sec = 10;
119
        tv.tv_usec = 0;
120
 
121
        if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(int)) == -1)
122
        {
93 andreas 123
            MSG_ERROR("[" << mHost << "] Error setting socket options for address reuse: " << strerror(errno));
86 andreas 124
            ::close(sock);
125
            return false;
126
        }
127
 
128
        if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(struct timeval)) == -1)
129
        {
93 andreas 130
            MSG_ERROR("[" << mHost << "] Error setting socket options for receive: " << strerror(errno));
86 andreas 131
            ::close(sock);
132
            return false;
133
        }
134
 
88 andreas 135
        if (setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (const char *)&tv, sizeof(struct timeval)) == -1)
136
        {
93 andreas 137
            MSG_ERROR("[" << mHost << "] Error setting socket options for send: " << strerror(errno));
88 andreas 138
            ::close(sock);
139
            return false;
140
        }
141
 
86 andreas 142
        if (::connect(sock, ainfo->ai_addr, ainfo->ai_addrlen) == -1)
143
        {
93 andreas 144
            if (errno != EINPROGRESS)
145
            {
146
                MSG_ERROR("[" << mHost << "] Connect error: " << strerror(errno));
147
                ::close(sock);
148
                mConnected = false;
149
                return false;
150
            }
151
            else
152
            {
153
                MSG_INFO("[" << mHost << "] Connection is in progress ...");
154
                mConnected = true;
155
                break;
156
            }
86 andreas 157
        }
158
        else
159
        {
93 andreas 160
            MSG_INFO("[" << mHost << "] Successfully connected.");
87 andreas 161
            mConnected = true;
86 andreas 162
            break;
163
        }
164
    }
165
 
166
    if (ainfo == nullptr)
87 andreas 167
    {
93 andreas 168
        MSG_ERROR("[" << mHost << "] No network interface to connect to target was found!");
87 andreas 169
        mConnected = false;
86 andreas 170
        return false;
87 andreas 171
    }
86 andreas 172
 
173
    if (encrypt)
174
    {
175
        int ret;
176
 
93 andreas 177
        MSG_DEBUG("[" << mHost << "] Initializing SSL connection ...");
86 andreas 178
        mCtx = initCTX();
179
 
180
        if (mCtx == NULL)
181
        {
93 andreas 182
            MSG_ERROR("[" << mHost << "] Error initializing CTX.");
86 andreas 183
            ::close(sock);
87 andreas 184
            mConnected = false;
86 andreas 185
            return false;
186
        }
187
 
188
        mSsl = SSL_new(mCtx);      /* create new SSL connection state */
189
 
190
        if (mSsl == NULL)
191
        {
192
            log_ssl_error();
193
            SSL_CTX_free(mCtx);
194
            ::close(sock);
87 andreas 195
            mConnected = false;
86 andreas 196
            return false;
197
        }
198
 
199
        SSL_set_fd(mSsl, sock);    /* attach the socket descriptor */
200
 
201
        if (TConfig::certCheck())
202
        {
203
            SSL_set_verify(mSsl, SSL_VERIFY_PEER, _cert_callback);
93 andreas 204
            MSG_TRACE("[" << mHost << "] Verify on peer certificate was set.");
86 andreas 205
        }
206
 
207
        while ((ret = SSL_connect(mSsl)) < 0)
208
        {
209
            fd_set fds;
210
            FD_ZERO(&fds);
211
            FD_SET(sock, &fds);
212
 
213
            switch (SSL_get_error(mSsl, ret))
214
            {
215
                case SSL_ERROR_WANT_READ:
216
                    select(sock + 1, &fds, NULL, NULL, NULL);
217
                break;
218
 
219
                case SSL_ERROR_WANT_WRITE:
220
                    select(sock + 1, NULL, &fds, NULL, NULL);
221
                break;
222
 
223
                default:
93 andreas 224
                    MSG_ERROR("[" << mHost << "] Error getting a new SSL handle.");
86 andreas 225
                    SSL_CTX_free(mCtx);
226
                    ::close(sock);
227
                    SSL_free(mSsl);
87 andreas 228
                    mConnected = false;
86 andreas 229
                    return false;
230
            }
231
        }
232
 
233
        if (TConfig::certCheck())
234
        {
235
            if (SSL_get_peer_certificate(mSsl))
236
            {
93 andreas 237
                MSG_DEBUG("[" << mHost << "] Result of peer certificate verification is checked ...");
86 andreas 238
 
93 andreas 239
                if (SSL_get_verify_result(mSsl) != X509_V_OK)
86 andreas 240
                {
93 andreas 241
                    MSG_ERROR("[" << mHost << "] Error verifiying peer.");
86 andreas 242
                    SSL_CTX_free(mCtx);
243
                    ::close(sock);
244
                    SSL_free(mSsl);
87 andreas 245
                    mConnected = false;
86 andreas 246
                    return false;
247
                }
248
 
93 andreas 249
                MSG_TRACE("[" << mHost << "] Certificate was valid.");
86 andreas 250
            }
251
            else
93 andreas 252
                MSG_WARNING("[" << mHost << "] Peer offered no or invalid certificate!");
86 andreas 253
        }
254
 
255
        mEncrypted = true;
256
    }
257
 
258
    mSockfd = sock;
259
    return true;
260
}
261
 
262
bool TSocket::connect(const string& host, int port, bool encrypt)
263
{
88 andreas 264
    DECL_TRACER("TSocket::connect(const string&, int port, bool encrypt)");
86 andreas 265
 
266
    if (host.empty() || port < 1)
267
    {
88 andreas 268
        MSG_ERROR("CONNECT: Invalid credentials! (HOST: " << (host.empty() ? "<none>" : host) << ", PORT: " << port << ")");
86 andreas 269
        return false;
270
    }
271
 
272
    if (mConnected && host == mHost && port == mPort)
87 andreas 273
    {
93 andreas 274
        MSG_INFO("[" << mHost << "] Already connected.");
86 andreas 275
        return true;
87 andreas 276
    }
86 andreas 277
 
278
    if (mConnected)
89 andreas 279
        close();
86 andreas 280
 
281
    mHost = host;
282
    mPort = port;
283
    return connect(encrypt);
284
}
285
 
93 andreas 286
bool TSocket::isSockValid()
287
{
288
    DECL_TRACER("TSocket::isSockValid()");
289
 
290
    if (!mConnected || mSockfd <= 0)
291
        return false;
292
 
293
    int optval;
294
    socklen_t optlen = sizeof(optval);
295
 
296
    int res = getsockopt(mSockfd, SOL_SOCKET, SO_ERROR, &optval, &optlen);
297
 
298
    if (optval == 0 && res == 0)
299
        return true;
300
 
301
    if (res != 0)
302
    {
303
        MSG_ERROR("[" << mHost << "] Network error: " << strerror(errno));
304
    }
305
 
306
    return false;
307
}
308
 
86 andreas 309
size_t TSocket::receive(char* buffer, size_t size)
310
{
311
    DECL_TRACER("TSocket::receive(char* buffer, size_t size)");
312
 
313
    int proto = 0;
88 andreas 314
    bool retry = false;
315
    std::chrono::system_clock::time_point end = std::chrono::system_clock::now() + std::chrono::seconds(10);
86 andreas 316
 
92 andreas 317
    if (!mConnected || buffer == nullptr || (mEncrypted && mSsl == nullptr))
94 andreas 318
        return npos;
86 andreas 319
 
320
    if (!mEncrypted)
321
        proto = 0;
322
    else
323
        proto = 1;
324
 
87 andreas 325
    struct pollfd pfd;
88 andreas 326
    int nfds = 1;       // Only one entry in structure
87 andreas 327
 
328
    pfd.fd = mSockfd;
329
    pfd.events = POLLIN;
330
 
88 andreas 331
    int s = 0;
332
 
333
    do
86 andreas 334
    {
88 andreas 335
        s = poll(&pfd, nfds, 10000);    // FIXME: Make the timeout configurable.
336
 
337
        if (s < 0)
87 andreas 338
        {
93 andreas 339
            close();
340
            XCEPTNETWORK("[" + mHost + "] Poll error on read: " + strerror(errno));
88 andreas 341
        }
342
 
343
        if (s == 0)
344
        {
345
            if (std::chrono::system_clock::now() < end)
97 andreas 346
            {
88 andreas 347
                retry = true;
97 andreas 348
                MSG_DEBUG("looping ...");
349
            }
88 andreas 350
            else
93 andreas 351
            {
352
                errno = ETIMEDOUT;
88 andreas 353
                retry = false;
93 andreas 354
            }
88 andreas 355
        }
356
        else
357
        {
87 andreas 358
            switch (proto)
359
            {
360
                case 0: return read(mSockfd, buffer, size);
361
                case 1: return SSL_read(mSsl, buffer, size);
362
            }
363
        }
86 andreas 364
    }
88 andreas 365
    while (retry);
366
 
94 andreas 367
    return npos;
88 andreas 368
}
369
 
370
size_t TSocket::readAbsolut(char *buffer, size_t size)
371
{
372
    DECL_TRACER("TSocket::readAbsolut(char *buffer, size_t size)");
373
 
92 andreas 374
    if (!mConnected || buffer == nullptr || !size)
94 andreas 375
        return npos;
88 andreas 376
 
377
    size_t rest = size;
378
    char *buf = new char[size + 1];
379
    char *p = buffer;
89 andreas 380
    std::chrono::system_clock::time_point end = std::chrono::system_clock::now() + std::chrono::seconds(10);
88 andreas 381
 
382
    while (rest && mConnected)
87 andreas 383
    {
88 andreas 384
        size_t rec = receive(buf, rest);
385
 
94 andreas 386
        if (rec != npos && rec > 0)
88 andreas 387
        {
388
            rest -= rec;
389
            memmove(p, buf, rec);
390
            p += rec;
89 andreas 391
            end = std::chrono::system_clock::now() + std::chrono::seconds(10);
88 andreas 392
        }
89 andreas 393
        else if (std::chrono::system_clock::now() >= end)
394
        {
93 andreas 395
            string message = "[" + mHost + "] Read: ";
88 andreas 396
 
89 andreas 397
            if (!mEncrypted)
93 andreas 398
            {
399
                if (errno)
400
                    message.append(strerror(errno));
401
                else
402
                    message.append("Timeout on reading");
403
            }
89 andreas 404
            else
405
            {
406
                log_ssl_error();
407
                message.append("Read error!");
408
            }
409
 
410
            close();
93 andreas 411
            delete[] buf;
412
            buf = nullptr;
413
#ifdef __ANDROID__
414
            MSG_ERROR(message);
415
            return -1;
416
#else
89 andreas 417
            XCEPTNETWORK(message);
93 andreas 418
#endif
89 andreas 419
        }
420
 
88 andreas 421
        if (rest)
422
            std::this_thread::sleep_for(std::chrono::microseconds(1000));
87 andreas 423
    }
86 andreas 424
 
93 andreas 425
    if (buf)
426
        delete[] buf;
427
 
89 andreas 428
    return (size - rest);
86 andreas 429
}
430
 
431
size_t TSocket::send(char* buffer, size_t size)
432
{
433
    DECL_TRACER("TSocket::send(char* buffer, size_t size)");
434
 
435
    int proto = 0;
93 andreas 436
    bool retry = false;
437
    std::chrono::system_clock::time_point end = std::chrono::system_clock::now() + std::chrono::seconds(10);
86 andreas 438
 
88 andreas 439
    if (!mConnected || buffer == nullptr || (mEncrypted && mSsl == nullptr))
94 andreas 440
        return npos;
86 andreas 441
 
442
    if (!mEncrypted)
443
        proto = 0;
444
    else
445
        proto = 1;
446
 
93 andreas 447
    struct pollfd pfd;
448
    int nfds = 1;       // Only one entry in structure
449
 
450
    pfd.fd = mSockfd;
451
    pfd.events = POLLOUT;
452
 
453
    int s = 0;
454
 
455
    do
86 andreas 456
    {
93 andreas 457
        s = poll(&pfd, nfds, 10000);    // FIXME: Make the timeout configurable.
458
 
459
        if (s < 0)
460
        {
461
            close();
462
            XCEPTNETWORK("[" + mHost + "] Poll error on write: " + strerror(errno));
463
        }
464
 
465
        if (s == 0)
466
        {
467
            if (std::chrono::system_clock::now() < end)
468
                retry = true;
469
            else
470
            {
471
                retry = false;
472
                errno = ETIMEDOUT;
473
            }
474
        }
475
        else
476
        {
477
            switch (proto)
478
            {
479
                case 0: return write(mSockfd, buffer, size);
480
                case 1: return SSL_write(mSsl, buffer, size);
481
            }
482
        }
86 andreas 483
    }
93 andreas 484
    while (retry);
86 andreas 485
 
94 andreas 486
    return npos;
86 andreas 487
}
488
 
489
bool TSocket::close()
490
{
491
    DECL_TRACER("TSocket::close()");
492
 
89 andreas 493
    bool status = true;
494
 
86 andreas 495
    if (!mConnected)
496
        return true;
497
 
87 andreas 498
    if (mEncrypted && mSsl)
86 andreas 499
    {
87 andreas 500
        SSL_free(mSsl);
501
        mSsl = nullptr;
86 andreas 502
    }
503
 
93 andreas 504
    if (!isSockValid())
505
    {
506
        mConnected = false;
507
 
508
        if (mEncrypted && mCtx)
509
        {
510
            SSL_CTX_free(mCtx);
511
            mCtx = nullptr;
512
        }
513
 
514
        mSockfd = -1;
515
        mEncrypted = false;
516
        return false;
517
    }
518
 
87 andreas 519
    if (shutdown(mSockfd, SHUT_RDWR) != 0)
520
    {
93 andreas 521
        MSG_ERROR("[" << mHost << "] Error shutting down connection: " << strerror(errno));
89 andreas 522
        status = false;
87 andreas 523
    }
524
 
525
    mConnected = false;
526
 
86 andreas 527
    if (::close(mSockfd) != 0)
528
    {
93 andreas 529
        MSG_ERROR("[" << mHost << "] Error closing a socket: " << strerror(errno));
89 andreas 530
        status = false;
86 andreas 531
    }
532
 
88 andreas 533
    mSockfd = -1;
534
 
87 andreas 535
    if (mEncrypted && mCtx)
536
    {
537
        SSL_CTX_free(mCtx);
538
        mCtx = nullptr;
539
    }
540
 
86 andreas 541
    mEncrypted = false;
89 andreas 542
    return status;
86 andreas 543
}
544
 
545
struct addrinfo *TSocket::lookup_host (const string& host, int port)
546
{
88 andreas 547
    DECL_TRACER("TSocket::lookup_host (const string& host, int port)");
86 andreas 548
 
549
    struct addrinfo *res;
550
    struct addrinfo hints;
551
    char sport[16];
552
 
553
    memset (&hints, 0, sizeof (hints));
554
    hints.ai_family = AF_INET;
555
    hints.ai_protocol = IPPROTO_TCP;
556
    hints.ai_socktype = SOCK_STREAM;
557
    hints.ai_flags = AI_CANONNAME;
558
    snprintf(sport, sizeof(sport), "%d", port);
559
    int ret = 0;
560
 
561
    if ((ret = getaddrinfo (host.c_str(), sport, &hints, &res)) != 0)
562
    {
93 andreas 563
        MSG_ERROR("[" << mHost << "] Getaddrinfo: " << gai_strerror(ret));
86 andreas 564
        return nullptr;
565
    }
566
 
567
    return res;
568
}
569
 
570
void TSocket::initSSL()
571
{
88 andreas 572
    DECL_TRACER("TSocket::initSSL()");
86 andreas 573
 
574
    if (mSSLInitialized)
575
        return;
576
 
577
    SSL_library_init();
578
    ERR_load_BIO_strings();
579
    ERR_load_crypto_strings();
580
    SSL_load_error_strings();
581
    mSSLInitialized = true;
582
}
583
 
584
SSL_CTX *TSocket::initCTX()
585
{
88 andreas 586
    DECL_TRACER("TSocket::initCTX()");
86 andreas 587
 
588
    SSL_CTX *ctx;
88 andreas 589
#if OPENSSL_VERSION_NUMBER >= 0x1010000fL
86 andreas 590
    const SSL_METHOD *method = TLS_client_method();
88 andreas 591
#else
86 andreas 592
    const SSL_METHOD *method = TLSv1_2_client_method();
88 andreas 593
#endif
86 andreas 594
    ctx = SSL_CTX_new(method);   /* Create new context */
595
 
596
    if ( ctx == NULL )
597
    {
598
        log_ssl_error();
599
        return NULL;
600
    }
601
 
602
    char *cert_check = getenv("CERT_CHECK");
603
 
604
    if (cert_check && strcmp(cert_check, "ON") == 0)
605
    {
606
        char *cert_path = getenv("CERT_PATH");
607
        char *cert_chain = getenv("CERT_CHAIN");
608
        char *cert_file = getenv("CERT_FILE");
609
        char *cert_type = getenv("CERT_TYPE");
610
 
611
        if (cert_path == NULL)
612
        {
613
            MSG_WARNING("Missing environment variable \"CERT_PATH\" defining the path to the cerificates.");
614
            return ctx;
615
        }
616
 
617
        if (cert_chain == NULL)
618
        {
619
            MSG_WARNING("Certificate check is enabled but no certificate chain file is set! No certificate verification was made.");
620
            return ctx;
621
        }
622
 
623
        SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, _cert_callback);
624
 
625
        if (cert_type == NULL)
626
            cert_type = (char *)"PEM";
627
 
628
        if (SSL_CTX_load_verify_locations(ctx, cert_chain, cert_path) != 1)
629
        {
630
            MSG_ERROR("Error with certificate " << cert_path << "/" << cert_chain);
631
            log_ssl_error();
632
            SSL_CTX_free(ctx);
633
            return NULL;
634
        }
635
 
636
        int type = SSL_FILETYPE_PEM;
637
 
638
        if (strcmp(cert_type, "ASN1") == 0)
639
            type = SSL_FILETYPE_ASN1;
640
 
641
        if (cert_file && SSL_CTX_use_certificate_file(ctx, cert_file, type) != 1)
642
        {
643
            MSG_ERROR("Error with certificate " << cert_file);
644
            log_ssl_error();
645
            SSL_CTX_free(ctx);
646
            return NULL;
647
        }
648
    }
649
 
650
    return ctx;
651
}
652
 
653
void TSocket::log_ssl_error()
654
{
88 andreas 655
    DECL_TRACER("TSocket::log_ssl_error()");
86 andreas 656
    unsigned long int err;
657
    char errstr[512];
658
 
659
    while ((err = ERR_get_error()) != 0)
660
    {
661
        ERR_error_string_n(err, &errstr[0], sizeof(errstr));
662
        MSG_ERROR(errstr);
663
    }
664
}
665
 
666
/*
667
 * Callback fuction for SSL connections.
668
 */
669
int _cert_callback(int preverify_ok, X509_STORE_CTX *ctx)
670
{
671
    DECL_TRACER("_cert_callback(int preverify_ok, X509_STORE_CTX *ctx)");
672
 
673
    char    buf[256];
674
    X509   *err_cert;
675
    int     err, depth;
676
 
677
    err_cert = X509_STORE_CTX_get_current_cert(ctx);
678
    err = X509_STORE_CTX_get_error(ctx);
679
    depth = X509_STORE_CTX_get_error_depth(ctx);
680
 
681
    /*
682
     * Retrieve the pointer to the SSL of the connection currently treated
683
     * and the application specific data stored into the SSL object.
684
     */
88 andreas 685
    X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
86 andreas 686
    X509_NAME_oneline(X509_get_subject_name(err_cert), buf, 256);
687
 
688
    if (!preverify_ok)
689
    {
690
        MSG_WARNING("verify error:num=" << err << ":" << X509_verify_cert_error_string(err) << ":depth=" << depth << ":" << buf);
691
    }
692
 
693
    /*
694
     * At this point, err contains the last verification error. We can use
695
     * it for something special
696
     */
697
    if (!preverify_ok && (err == X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT))
698
    {
699
        X509_NAME_oneline(X509_get_issuer_name(err_cert), buf, 256);
700
        MSG_WARNING("issuer= " << buf);
701
    }
702
 
703
    return preverify_ok;
704
}