sipxportlib  Version 3.3
OsSSL.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 #ifndef _OsSSL_h_
12 #define _OsSSL_h__
13 
14 // SYSTEM INCLUDES
15 
16 // APPLICATION INCLUDES
17 #include "os/OsBSem.h"
18 #include "os/OsSysLog.h"
19 #include "openssl/ssl.h"
20 
21 // DEFINES
22 // MACROS
23 // EXTERNAL FUNCTIONS
24 // EXTERNAL VARIABLES
25 // CONSTANTS
26 // STRUCTS
27 // TYPEDEFS
28 // FORWARD DECLARATIONS
29 class UtlString;
30 class UtlSList;
31 
35 class OsSSL
36 {
37 /* //////////////////////////// PUBLIC //////////////////////////////////// */
38  public:
39 
41  OsSSL(const char* authorityPath = NULL,
44  const char* publicCertificatePath = NULL,
46  const char* privateKeyPath = NULL
51  );
52 
53  ~OsSSL();
54 
55 /* ============================ CREATORS ================================== */
56 
57 /* ============================ MANIPULATORS ============================== */
58 
59 /* ============================ ACCESSORS ================================= */
60 
62  SSL* getServerConnection();
63 
65  SSL* getClientConnection();
66 
68  void releaseConnection(SSL*& connection);
69 
71  static bool peerIdentity( SSL* connection
72  ,UtlSList* altNames
75  ,UtlString* commonName
76  );
86  static void logConnectParams(const OsSysLogFacility facility,
88  const OsSysLogPriority priority,
89  const char* callerMsg,
90  SSL* connection
91  );
92 
93 
95  static void logError(const OsSysLogFacility facility,
96  const OsSysLogPriority priority,
97  const char* callerMsg,
98  int errCode
99  );
100 
102  void dumpCipherList();
103 
104 /* ============================ INQUIRY =================================== */
105 
106 
107 /* //////////////////////////// PROTECTED ///////////////////////////////// */
108  protected:
109 
110 /* //////////////////////////// PRIVATE /////////////////////////////////// */
111  private:
112 
113  static bool sInitialized;
114 
115  SSL_CTX* mCTX;
116 
118  static int verifyCallback(int valid,
119  X509_STORE_CTX* store
120  );
126  OsSSL(const OsSSL& rOsSSL);
128 
130  OsSSL& operator=(const OsSSL& rhs);
131 };
132 
135 {
136  public:
137 
138  static OsSSL* get();
139 
140  private:
141 
142  static OsBSem* spSslLock;
143  static OsSSL* spSharedSSL;
144 
146  OsSharedSSL();
147 
148  ~OsSharedSSL();
149 
151  OsSharedSSL(const OsSharedSSL& r);
152 
154  OsSharedSSL& operator=(const OsSharedSSL& rhs);
155 };
156 
157 
158 
159 /* ============================ INLINE METHODS ============================ */
160 
161 #endif // _OsSSL_h_
enum tagOsSysLogFacility OsSysLogFacility
enumcode: FAC_PERF - performance related enumcode: FAC_KERNEL - kernel/os related enumcode: FAC_AUTH ...
Definition: OsSysLogFacilities.h:140
void releaseConnection(SSL *&connection)
Release an SSL session handle.
SSL * getServerConnection()
Get an SSL server connection handle.
Wrapper for the OpenSSL SSL_CTX context structure. This class is responsible for all global policy in...
Definition: OsSSL.h:35
#define NULL
Definition: UtlDefs.h:29
Definition: UtlString.h:48
enum tagOsSysLogPriority OsSysLogPriority
Definition: UtlSList.h:47
static void logError(const OsSysLogFacility facility, const OsSysLogPriority priority, const char *callerMsg, int errCode)
Log an error resulting from an SSL call, with the SSL error text expanded.
static void logConnectParams(const OsSysLogFacility facility, const OsSysLogPriority priority, const char *callerMsg, SSL *connection)
Log SSL connection information.
SSL * getClientConnection()
Get an SSL client connection handle.
OsSSL(const char *authorityPath=NULL, const char *publicCertificatePath=NULL, const char *privateKeyPath=NULL)
Construct an SSL Context from which connections are created.
static bool peerIdentity(SSL *connection, UtlSList *altNames, UtlString *commonName)
Get the validated names for the connection peer.
A singleton wrapper for OsSSL.
Definition: OsSSL.h:134
void dumpCipherList()
Debug: print out list of ciphers enabled.