live
TLSState.hh
Go to the documentation of this file.
1 /**********
2 This library is free software; you can redistribute it and/or modify it under
3 the terms of the GNU Lesser General Public License as published by the
4 Free Software Foundation; either version 3 of the License, or (at your
5 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6 
7 This library is distributed in the hope that it will be useful, but WITHOUT
8 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10 more details.
11 
12 You should have received a copy of the GNU Lesser General Public License
13 along with this library; if not, write to the Free Software Foundation, Inc.,
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 **********/
16 // "liveMedia"
17 // Copyright (c) 1996-2021 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 
37 class TLSState {
38 public:
40 
41  int write(const char* data, unsigned count);
42  int read(u_int8_t* buffer, unsigned bufferSize);
43 
44 protected: // we're an abstract base class
46  virtual ~TLSState();
47 
48 #ifndef NO_OPENSSL
49  void initLibrary();
50  void reset();
51 
52 protected:
54  SSL_CTX* fCtx;
55  SSL* fCon;
56 #endif
57 };
58 
59 class ClientTLSState: public TLSState {
60 public:
61  ClientTLSState(class RTSPClient& client);
62  virtual ~ClientTLSState();
63 
64  int connect(int socketNum); // returns: <0 (error), 0 (pending), >0 (success)
65 
66 #ifndef NO_OPENSSL
67 private:
68  Boolean setup(int socketNum);
69 
70 private:
72 #endif
73 };
74 
75 class ServerTLSState: public TLSState {
76 public:
78  virtual ~ServerTLSState();
79 
80  void setCertificateAndPrivateKeyFileNames(char const* certFileName, char const* privKeyFileName);
81 
82  int accept(int socketNum); // returns: <0 (error), 0 (pending), >0 (success)
83 
85 
86 #ifndef NO_OPENSSL
87 private:
88  Boolean setup(int socketNum);
89 
90 private:
92  char const* fCertificateFileName;
93  char const* fPrivateKeyFileName;
94 #endif
95 };
96 
97 #endif
unsigned char Boolean
Definition: Boolean.hh:25
int connect(int socketNum)
class RTSPClient & fClient
Definition: TLSState.hh:71
virtual ~ClientTLSState()
ClientTLSState(class RTSPClient &client)
Boolean setup(int socketNum)
char const * fPrivateKeyFileName
Definition: TLSState.hh:93
ServerTLSState(UsageEnvironment &env)
UsageEnvironment & fEnv
Definition: TLSState.hh:91
void setCertificateAndPrivateKeyFileNames(char const *certFileName, char const *privKeyFileName)
int accept(int socketNum)
Boolean setup(int socketNum)
virtual ~ServerTLSState()
Boolean tlsAcceptIsNeeded
Definition: TLSState.hh:84
char const * fCertificateFileName
Definition: TLSState.hh:92
SSL * fCon
Definition: TLSState.hh:55
Boolean isNeeded
Definition: TLSState.hh:39
void reset()
int write(const char *data, unsigned count)
virtual ~TLSState()
void initLibrary()
SSL_CTX * fCtx
Definition: TLSState.hh:54
Boolean fHasBeenSetup
Definition: TLSState.hh:53
int read(u_int8_t *buffer, unsigned bufferSize)