sipxportlib  Version 3.3
OsTLS.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 _OsTLS_h_
12 #define _OsTLS_h_
13 
14 
15 
16 // SYSTEM INCLUDES
17 
18 // APPLICATION INCLUDES
19 #include "os/OsBSem.h"
20 #include "os/OsSysLog.h"
21 #include "utl/UtlString.h"
22 #include "utl/UtlHashMap.h"
23 
24 #include <nspr.h>
25 #include <seccomon.h>
26 #include <secmod.h>
27 
28 // DEFINES
29 // MACROS
30 // EXTERNAL FUNCTIONS
31 // EXTERNAL VARIABLES
32 // CONSTANTS
33 #define MAX_CERT_DIR_LENGTH 256
34 // STRUCTS
35 // ENUMERATIONS
36 typedef enum SECURITY_CAUSE
37 {
70 
71 // TYPEDEFS
72 // FORWARD DECLARATIONS
73 
74 
75 class ITlsSink
76 {
77 public:
78  virtual bool onServerCertificate(void* pCert, char* serverHostName) = 0;
79  virtual bool onTlsEvent(int cause) = 0;
80 };
81 
82 #ifdef SIP_TLS_NSS
83 // Singleton class for invoking NSS functions.
84 class OsTLS
85 {
86 /* //////////////////////////// PUBLIC //////////////////////////////////// */
87 private:
88  OsTLS();
89 public:
90  virtual ~OsTLS();
91 
92 
93  static OsStatus Initialize(const char* szCertDir);
94  static SECStatus GetClientAuthData(void *arg,
95  PRFileDesc *socket,
96  struct CERTDistNamesStr *caNames,
97  struct CERTCertificateStr **pRetCert,
98  struct SECKEYPrivateKeyStr **pRetKey);
99 
100  static SECStatus AuthCertificate(void *arg,
101  PRFileDesc *socket,
102  PRBool checksig,
103  PRBool isServer) ;
104 
105  static SECStatus BadCertHandler(void *arg, PRFileDesc *socket);
106  static SECStatus HandshakeCallback(PRFileDesc *socket, void *arg);
107  static char* PasswordCallback(PK11SlotInfo *slot, PRBool retry, void *arg);
108 
109  static void setTlsSink(PRFileDesc* key, ITlsSink* pSink);
110  static ITlsSink* getTlsSink(PRFileDesc* key);
111  static void removeTlsSink(PRFileDesc* key);
112 private:
113 
114  static UtlHashMap* mpSinkMap;
115 };
116 
117 
118 
119 
120 /* ============================ INLINE METHODS ============================ */
121 
122 #endif
123 
124 #endif // _OsTLS_h_
Definition: OsTLS.h:42
Definition: OsTLS.h:48
Definition: OsTLS.h:61
SECURITY_CAUSE
Definition: OsTLS.h:36
Definition: OsTLS.h:56
OsStatus
Definition: OsStatus.h:27
Definition: OsTLS.h:75
Definition: OsTLS.h:43
Definition: UtlHashMap.h:46
virtual bool onTlsEvent(int cause)=0
Definition: OsTLS.h:38
virtual bool onServerCertificate(void *pCert, char *serverHostName)=0