reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
TurnTlsSocket.hxx
Go to the documentation of this file.
1
2#if defined(HAVE_CONFIG_H)
3 #include "config.h"
4#endif
5
6#ifdef USE_SSL
7#ifndef TURNTLSSOCKET_HXX
8#define TURNTLSSOCKET_HXX
9
10#include <memory>
11
12#include <asio.hpp>
13#include <asio/ssl.hpp>
14
15#include "TurnTcpSocket.hxx"
16
17namespace reTurn {
18
20{
21public:
26 const asio::ip::address& address = UnspecifiedIpAddress,
27 unsigned short port = 0,
28 const std::string& rootCertificatesFile = "ca.pem");
29
30 virtual unsigned int getSocketDescriptor() { return (unsigned int)mSocket->lowest_layer().native_handle(); }
31 virtual asio::error_code connect(const std::string& address, unsigned short port);
32
33protected:
34 virtual asio::error_code rawWrite(const char* buffer, unsigned int size);
35 virtual asio::error_code rawWrite(const std::vector<asio::const_buffer>& buffers);
36
37 virtual void readHeader();
38 virtual void readBody(unsigned int len);
39 virtual void cancelSocket();
40
41private:
42 asio::ssl::context mSslContext;
43 // Made again for each connection attempt: once a handshake has failed, its SSL object can't
44 // be used for another
45 std::unique_ptr<asio::ssl::stream<asio::ip::tcp::socket>> mSocket;
46 bool mValidateServerCertificateHostname;
47};
48
49}
50
51#endif
52#endif
53
54/* ====================================================================
55
56 Copyright (c) 2008-2026 SIP Spectrum, Inc. https://www.sipspectrum.com
57 Copyright (c) 2007-2008, Plantronics, Inc.
58 All rights reserved.
59
60 Redistribution and use in source and binary forms, with or without
61 modification, are permitted provided that the following conditions are
62 met:
63
64 1. Redistributions of source code must retain the above copyright
65 notice, this list of conditions and the following disclaimer.
66
67 2. Redistributions in binary form must reproduce the above copyright
68 notice, this list of conditions and the following disclaimer in the
69 documentation and/or other materials provided with the distribution.
70
71 3. Neither the name of Plantronics nor the names of its contributors
72 may be used to endorse or promote products derived from this
73 software without specific prior written permission.
74
75 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
76 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
77 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
78 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
79 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
80 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
81 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
82 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
83 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
84 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
85 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
86
87 ==================================================================== */
static asio::ip::address UnspecifiedIpAddress
virtual void cancelSocket()
virtual asio::error_code rawWrite(const char *buffer, unsigned int size)
virtual void readBody(unsigned int len)
virtual asio::error_code connect(const std::string &address, unsigned short port)
virtual unsigned int getSocketDescriptor()
virtual void readHeader()
void list()
Definition userAdmin.cxx:66