PTLib  Version 2.14.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PSSLContext Class Reference

Context for SSL channels. More...

#include <pssl.h>

Inheritance diagram for PSSLContext:
Collaboration diagram for PSSLContext:

Public Types

enum  Method { SSLv23, SSLv3, TLSv1 }
 
- Public Types inherited from PObject
enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
 Result of the comparison operation performed by the Compare() function. More...
 

Public Member Functions

 PSSLContext (const void *sessionId=NULL, PINDEX idSize=0)
 Create a new context for SSL channels. More...
 
 PSSLContext (Method method, const void *sessionId=NULL, PINDEX idSize=0)
 
 ~PSSLContext ()
 Clean up the SSL context. More...
 
 operator ssl_ctx_st * () const
 Get the internal SSL context structure. More...
 
bool SetVerifyLocations (const PFilePath &caFile, const PDirectory &caDir)
 Set the locations for CA certificates used to verify peer certificates. More...
 
bool SetVerifyCertificate (const PSSLCertificate &cert)
 Set the CA certificate used to verify peer certificates. More...
 
 P_DECLARE_ENUM (VerifyMode, VerifyNone, VerifyPeer, VerifyPeerMandatory)
 
void SetVerifyMode (VerifyMode mode, unsigned depth=9)
 Set certificate verification mode for connection. More...
 
VerifyMode GetVerifyMode () const
 Set certificate verification mode for connection. More...
 
bool AddClientCA (const PSSLCertificate &certificate)
 Set the CA certificate(s) to send to client from server. More...
 
bool AddClientCA (const PList< PSSLCertificate > &certificates)
 
bool UseCertificate (const PSSLCertificate &certificate)
 Use the certificate specified. More...
 
bool UsePrivateKey (const PSSLPrivateKey &key)
 Use the private key specified. More...
 
bool UseDiffieHellman (const PSSLDiffieHellman &dh)
 Use the Diffie-Hellman parameters specified. More...
 
bool SetCipherList (const PString &ciphers)
 Set the available ciphers to those listed. More...
 
bool SetCredentials (const PString &authority, const PString &certificate, const PString &privateKey, bool create=false)
 Set the credentials for the context. More...
 
void SetPasswordNotifier (const PSSLPasswordNotifier &notifier)
 Set the notifier for when SSL needs to get a password to unlock a private key. More...
 
- Public Member Functions inherited from PObject
unsigned GetTraceContextIdentifier () const
 Get PTRACE context identifier. More...
 
void SetTraceContextIdentifier (unsigned id)
 
void GetTraceContextIdentifier (PObject &obj)
 
void GetTraceContextIdentifier (PObject *obj)
 
void SetTraceContextIdentifier (const PObject &obj)
 
void SetTraceContextIdentifier (const PObject *obj)
 
virtual ~PObject ()
 
virtual PObjectClone () const
 Create a copy of the class on the heap. More...
 
template<class CLS >
CLS * CloneAs () const
 As for Clone() but converts to specified type. More...
 
virtual PINDEX HashFunction () const
 This function yields a hash value required by the PDictionary class. More...
 
virtual const char * GetClass (unsigned ancestor=0) const
 Get the current dynamic type of the object instance. More...
 
PBoolean IsClass (const char *cls) const
 
virtual PBoolean InternalIsDescendant (const char *clsName) const
 Determine if the dynamic type of the current instance is a descendent of the specified class. More...
 
__inline const PObjectPTraceObjectInstance () const
 
virtual Comparison Compare (const PObject &obj) const
 Compare the two objects and return their relative rank. More...
 
virtual Comparison CompareObjectMemoryDirect (const PObject &obj) const
 Determine the byte wise comparison of two objects. More...
 
bool operator== (const PObject &obj) const
 Compare the two objects. More...
 
bool operator!= (const PObject &obj) const
 Compare the two objects. More...
 
bool operator< (const PObject &obj) const
 Compare the two objects. More...
 
bool operator> (const PObject &obj) const
 Compare the two objects. More...
 
bool operator<= (const PObject &obj) const
 Compare the two objects. More...
 
bool operator>= (const PObject &obj) const
 Compare the two objects. More...
 
virtual void PrintOn (ostream &strm) const
 Output the contents of the object to the stream. More...
 
virtual void ReadFrom (istream &strm)
 Input the contents of the object from the stream. More...
 

Protected Member Functions

void Construct (Method method, const void *sessionId, PINDEX idSize)
 
- Protected Member Functions inherited from PObject
 PObject ()
 Constructor for PObject, made protected so cannot ever create one on its own. More...
 

Protected Attributes

ssl_ctx_st * m_context
 
PSSLPasswordNotifier m_passwordNotifier
 
- Protected Attributes inherited from PObject
unsigned m_traceContextIdentifier
 

Additional Inherited Members

- Static Public Member Functions inherited from PObject
static const char * Class ()
 Get the name of the class as a C string. More...
 
static __inline const PObjectPTraceObjectInstance (const char *)
 
static __inline const PObjectPTraceObjectInstance (const PObject *obj)
 
static Comparison InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
 Internal function caled from CompareObjectMemoryDirect() More...
 
- Friends inherited from PObject

Detailed Description

Context for SSL channels.

This class embodies a common environment for all connections made via SSL using the PSSLChannel class. It includes such things as the version of SSL and certificates, CA's etc.

Member Enumeration Documentation

Enumerator
SSLv23 
SSLv3 
TLSv1 

Constructor & Destructor Documentation

PSSLContext::PSSLContext ( const void *  sessionId = NULL,
PINDEX  idSize = 0 
)

Create a new context for SSL channels.

An optional session ID may be provided in the context. This is used to identify sessions across multiple channels in this context. The session ID is a completely arbitrary block of data. If sessionId is non NULL and idSize is zero, then sessionId is assumed to be a pointer to a C string. The default SSL method is TLSv1

Parameters
sessionIdPointer to session ID
idSizeSize of session ID
PSSLContext::PSSLContext ( Method  method,
const void *  sessionId = NULL,
PINDEX  idSize = 0 
)
Parameters
methodSSL connection method
sessionIdPointer to session ID
idSizeSize of session ID
PSSLContext::~PSSLContext ( )

Clean up the SSL context.

Member Function Documentation

bool PSSLContext::AddClientCA ( const PSSLCertificate certificate)

Set the CA certificate(s) to send to client from server.

bool PSSLContext::AddClientCA ( const PList< PSSLCertificate > &  certificates)
void PSSLContext::Construct ( Method  method,
const void *  sessionId,
PINDEX  idSize 
)
protected
VerifyMode PSSLContext::GetVerifyMode ( ) const

Set certificate verification mode for connection.

PSSLContext::operator ssl_ctx_st * ( ) const
inline

Get the internal SSL context structure.

References m_context.

PSSLContext::P_DECLARE_ENUM ( VerifyMode  ,
VerifyNone  ,
VerifyPeer  ,
VerifyPeerMandatory   
)
bool PSSLContext::SetCipherList ( const PString ciphers)

Set the available ciphers to those listed.

Parameters
ciphersList of cipher names.
bool PSSLContext::SetCredentials ( const PString authority,
const PString certificate,
const PString privateKey,
bool  create = false 
)

Set the credentials for the context.

Parameters
authorityCertificate Authority directory, file or data
certificateLocal certificate file or data
privateKeyPrivate key file or data for local certificate
createIf certificate/provateKey are file paths and do not exist, then create.
void PSSLContext::SetPasswordNotifier ( const PSSLPasswordNotifier notifier)

Set the notifier for when SSL needs to get a password to unlock a private key.

Parameters
notifierNotifier to be called
bool PSSLContext::SetVerifyCertificate ( const PSSLCertificate cert)

Set the CA certificate used to verify peer certificates.

bool PSSLContext::SetVerifyLocations ( const PFilePath caFile,
const PDirectory caDir 
)

Set the locations for CA certificates used to verify peer certificates.

Parameters
caFileFile for CA certificates
caDirDirectory for CA certificates
void PSSLContext::SetVerifyMode ( VerifyMode  mode,
unsigned  depth = 9 
)

Set certificate verification mode for connection.

Parameters
modeNew verification mode
depthVerification depth (max number of certs in chain)
bool PSSLContext::UseCertificate ( const PSSLCertificate certificate)

Use the certificate specified.

bool PSSLContext::UseDiffieHellman ( const PSSLDiffieHellman dh)

Use the Diffie-Hellman parameters specified.

bool PSSLContext::UsePrivateKey ( const PSSLPrivateKey key)

Use the private key specified.

Member Data Documentation

ssl_ctx_st* PSSLContext::m_context
protected

Referenced by operator ssl_ctx_st *().

PSSLPasswordNotifier PSSLContext::m_passwordNotifier
protected

The documentation for this class was generated from the following file: