sipxportlib  Version 3.3
OsTLSServerSocket.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 SIPez LLC.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2004-2006 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
9 // Licensed to SIPfoundry under a Contributor Agreement.
10 //
11 // $$
13 
14 
15 #ifndef _OsTLSServerSocket_h_
16 #define _OsTLSServerSocket_h_
17 
18 #ifdef SIP_TLS
19 #ifdef SIP_TLS_NSS
20 
21 // SYSTEM INCLUDES
22 //#include <...>
23 
24 // APPLICATION INCLUDES
25 #include <os/OsConnectionSocket.h>
26 #include <os/OsServerSocket.h>
28 #include <os/OsFS.h>
29 
30 // DEFINES
31 // MACROS
32 // EXTERNAL FUNCTIONS
33 // EXTERNAL VARIABLES
34 // CONSTANTS
35 // STRUCTS
36 // TYPEDEFS
37 // FORWARD DECLARATIONS
38 enum TlsInitCodes
39 {
40  TLS_INIT_SUCCESS,
41  TLS_INIT_DATABASE_FAILURE,
42  TLS_INIT_BAD_PASSWORD,
43  TLS_INIT_TCP_IMPORT_FAILURE,
44  TLS_INIT_NSS_FAILURE
45 };
46 
47 class OsTLSServerSocket : public OsServerSocket
48 {
49 /* //////////////////////////// PUBLIC //////////////////////////////////// */
50 public:
51 
52 /* ============================ CREATORS ================================== */
53 
55  OsTLSServerSocket(int connectionQueueSize,
58  int serverPort=PORT_DEFAULT,
61  UtlString certNickname = "",
62  UtlString certPassword = "",
63  UtlString dbLocation = "",
64  const UtlString bindAddress = ""
65  );
71  OsTLSServerSocket& operator=(const OsTLSServerSocket& rhs);
73 
74  virtual
75  ~OsTLSServerSocket();
76  //:Destructor
77 
78 
79 /* ============================ MANIPULATORS ============================== */
80 
81  virtual OsConnectionSocket* accept();
82  //:Blocking accept of next connection
83  // Blocks and waits for the next TCP connection request.
86 
87 
88  virtual void close();
89  //: Close down the server
90 
91 /* ============================ ACCESSORS ================================= */
92 
93  virtual int getLocalHostPort() const;
94  //:Return the local port number
95  // Returns the port to which this socket is bound on this host.
96 
97 /* ============================ INQUIRY =================================== */
98 
99  virtual OsSocket::IpProtocolSocketType getIpProtocol() const;
100  //: Returns the protocol type of this socket
101 
102  virtual UtlBoolean isOk() const;
103  //: Server socket is in ready to accept incoming conection requests.
104 
105  int isConnectionReady();
106  //: Poll to see if connections are waiting
109 
110  TlsInitCodes getTlsInitCode() { return mTlsInitCode; }
111 /* //////////////////////////// PROTECTED ///////////////////////////////// */
112 protected:
113 
114 /* //////////////////////////// PRIVATE /////////////////////////////////// */
115 private:
116 
117  static int pemPasswdCallbackFunc(char *buf, int size, int rwflag, void *userdata);
118  //:Callback used to set the private key password for decrypting the key
119  //:buf is the buffer to fill with a password
120  //:size is the maximum size of the buffer
121 
122  OsTLSServerSocket(const OsTLSServerSocket& rOsTLSServerSocket);
123  //:Disable copy constructor
124 
125  OsTLSServerSocket();
126  //:Disable default constructor
127 
128  UtlString mCertNickname;
129  UtlString mCertPassword;
130  UtlString mDbLocation;
131 
132  PRFileDesc* mpMozillaSSLSocket;
133  SECKEYPrivateKey * mpPrivKey;
134  CERTCertificate * mpCert;
135  TlsInitCodes mTlsInitCode;
136 
137 };
138 
139 /* ============================ INLINE METHODS ============================ */
140 
141 #endif // SIP_TLS
142 #endif // SIP_TLS_NSS
143 
144 #endif // _OsTLSServerSocket_h_
145 
IpProtocolSocketType
Definition: OsSocket.h:92
int isConnectionReady()
virtual UtlBoolean isOk() const
Definition: OsServerSocket.cpp:279
virtual void close()
returns: Returns a socket connected to the client requesting the returns: connection. If an error occurs returns NULL.
Definition: OsServerSocket.cpp:234
Definition: UtlString.h:48
virtual int getLocalHostPort() const
Definition: OsServerSocket.cpp:267
virtual OsConnectionSocket * accept()
Definition: OsServerSocket.cpp:205
Definition: OsConnectionSocket.h:34
int UtlBoolean
Definition: UtlDefs.h:41
Definition: OsServerSocket.h:38
#define PORT_DEFAULT
Definition: OsDefs.h:180
OsServerSocket & operator=(const OsServerSocket &rhs)
param: connectionQueueSize - The maximum number of outstanding
Definition: OsServerSocket.cpp:197