Skip to content
Snippets Groups Projects
Select Git revision
  • c59f951e5aa89313460fb5037d382b95550c04d0
  • master default
  • windows_ci_static
  • c_link
  • cpack
  • windows_ci
  • cert_pk_id
  • proxy_push_result
  • cnode_put_id
  • update-windows-build
  • proxy
  • resubscribe_on_token_change
  • actions
  • client_mode
  • llhttp
  • search_node_add
  • crypto_aes_gcm_argon2
  • ios_notifications
  • log_fmt
  • v2asio
  • fix-msvc
  • v3.4.0
  • v3.3.1
  • v3.3.1rc1
  • v3.3.1rc2
  • v3.3.0
  • v3.2.0
  • v3.1.11
  • v3.1.10
  • v3.1.9
  • v3.1.8.2
  • v3.1.8.1
  • v3.1.8
  • v3.1.7
  • v3.1.6
  • v3.1.5
  • v3.1.4
  • v3.1.3
  • v3.1.2
  • v3.1
  • v3.0.1
41 results

dht_proxy_server.cpp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    peer_connection.cpp 25.84 KiB
    /*
     *  Copyright (C) 2017-2019 Savoir-faire Linux Inc.
     *
     *  Author: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
     *  Author: Sébastien Blin <sebastien.blin@savoirfairelinux.com>
     *
     *  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 3 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.
     */
    
    #include "peer_connection.h"
    
    #include "data_transfer.h"
    #include "manager.h"
    #include "jamidht/jamiaccount.h"
    #include "string_utils.h"
    #include "channel.h"
    #include "turn_transport.h"
    #include "security/tls_session.h"
    
    #include <algorithm>
    #include <future>
    #include <vector>
    #include <atomic>
    #include <stdexcept>
    #include <istream>
    #include <ostream>
    #include <unistd.h>
    #include <cstdio>
    
    #ifdef _WIN32
    #include <winsock2.h>
    #include <ws2tcpip.h>
    #else
    #include <sys/select.h>
    #endif
    
    #ifndef _MSC_VER
    #include <sys/time.h>
    #endif
    
    namespace jami {
    
    int
    init_crt(gnutls_session_t session, dht::crypto::Certificate& crt)
    {
        // Support only x509 format
        if (gnutls_certificate_type_get(session) != GNUTLS_CRT_X509) {
            return GNUTLS_E_CERTIFICATE_ERROR;
        }
    
        // Store verification status
        unsigned int status = 0;
        auto ret = gnutls_certificate_verify_peers2(session, &status);
        if (ret < 0 or (status & GNUTLS_CERT_SIGNATURE_FAILURE) != 0) {
            return GNUTLS_E_CERTIFICATE_ERROR;
        }
    
        unsigned int cert_list_size = 0;