live
TLSState.hh
Go to the documentation of this file.
1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15**********/
16// "liveMedia"
17// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
18// State encapsulating a TLS connection
19// C++ header
20
21#ifndef _TLS_STATE_HH
22#define _TLS_STATE_HH
23
24#ifndef _NET_COMMON_H
25#include "NetCommon.h"
26#endif
27#ifndef _BOOLEAN_HH
28#include "Boolean.hh"
29#endif
30#ifndef _USAGE_ENVIRONMENT_HH
31#include "UsageEnvironment.hh"
32#endif
33#ifndef NO_OPENSSL
34#include <openssl/ssl.h>
35#endif
36
37class TLSState {
38public:
40
41 int write(const char* data, unsigned count);
42 int read(u_int8_t* buffer, unsigned bufferSize);
43
44 void nullify(); // clear the state so that the destructor will have no effect
45
46protected: // we're an abstract base class
48 virtual ~TLSState();
49
50#ifndef NO_OPENSSL
52 void reset();
53
54protected:
56 SSL_CTX* fCtx;
57 SSL* fCon;
58#endif
59};
60
61class ClientTLSState: public TLSState {
62public:
63 ClientTLSState(class RTSPClient& client);
64 virtual ~ClientTLSState();
65
66 int connect(int socketNum); // returns: <0 (error), 0 (pending), >0 (success)
67
68#ifndef NO_OPENSSL
69private:
70 Boolean setup(int socketNum);
71
72private:
74#endif
75};
76
77class ServerTLSState: public TLSState {
78public:
80 virtual ~ServerTLSState();
81
82 void setCertificateAndPrivateKeyFileNames(char const* certFileName, char const* privKeyFileName);
84
85 int accept(int socketNum); // returns: <0 (error), 0 (pending), >0 (success)
86
88
89#ifndef NO_OPENSSL
90private:
91 Boolean setup(int socketNum);
92
93private:
97#endif
98};
99
100#endif
unsigned char Boolean
Definition: Boolean.hh:25
int connect(int socketNum)
class RTSPClient & fClient
Definition: TLSState.hh:73
virtual ~ClientTLSState()
ClientTLSState(class RTSPClient &client)
Boolean setup(int socketNum)
void assignStateFrom(ServerTLSState const &from)
char const * fPrivateKeyFileName
Definition: TLSState.hh:96
ServerTLSState(UsageEnvironment &env)
UsageEnvironment & fEnv
Definition: TLSState.hh:94
void setCertificateAndPrivateKeyFileNames(char const *certFileName, char const *privKeyFileName)
int accept(int socketNum)
Boolean setup(int socketNum)
virtual ~ServerTLSState()
Boolean tlsAcceptIsNeeded
Definition: TLSState.hh:87
char const * fCertificateFileName
Definition: TLSState.hh:95
SSL * fCon
Definition: TLSState.hh:57
Boolean isNeeded
Definition: TLSState.hh:39
void reset()
int write(const char *data, unsigned count)
virtual ~TLSState()
void nullify()
void initLibrary()
SSL_CTX * fCtx
Definition: TLSState.hh:56
Boolean fHasBeenSetup
Definition: TLSState.hh:55
int read(u_int8_t *buffer, unsigned bufferSize)