PTLib  Version 2.18.8
 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 Member Functions

 P_DECLARE_TRACED_ENUM (Method, SSLv23, SSLv3, TLSv1, TLSv1_1, TLSv1_2, DTLSv1, DTLSv1_2, DTLSv1_2_v1_0)
 
 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 SetVerifyDirectory (const PDirectory &caDir)
 Set the locations for CA certificates used to verify peer certificates. More...
 
bool SetVerifyFile (const PFilePath &caFile)
 Set the locations for CA certificates used to verify peer certificates. More...
 
bool SetVerifySystemDefault ()
 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...
 
bool SetExtension (const char *extension)
 Set TLS extension. More...
 
Method GetMethod () const
 
- Public Member Functions inherited from PObject
__inline unsigned GetTraceContextIdentifier () const
 Get PTRACE context identifier. More...
 
__inline void SetTraceContextIdentifier (unsigned id)
 
__inline void SetTraceContextIdentifier (const PObject &obj)
 
__inline void SetTraceContextIdentifier (const PObject *obj)
 
__inline void CopyTraceContextIdentifier (PObject &obj) const
 
__inline void CopyTraceContextIdentifier (PObject *obj) const
 
virtual ~PObject ()
 
__inline const char * GetClass () const
 
__inline bool IsClass (const char *name) const
 
__inline const PObjectPTraceObjectInstance () const
 
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 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...
 

Static Public Attributes

static const Method HighestTLS = TLSv1_2
 
static const Method HighestDTLS = DTLSv1_2_v1_0
 

Protected Member Functions

void Construct (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

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

Additional Inherited Members

- Public Types inherited from PObject
enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
 Result of the comparison operation performed by the Compare() function. More...
 
- Static Public Member Functions inherited from PObject
static __inline void CopyTraceContextIdentifier (PObject &to, const PObject &from)
 
static __inline void CopyTraceContextIdentifier (PObject &to, const PObject *from)
 
static __inline void CopyTraceContextIdentifier (PObject *to, const PObject &from)
 
static __inline void CopyTraceContextIdentifier (PObject *to, const PObject *from)
 
static __inline const char * Class ()
 
static __inline const PObjectPTraceObjectInstance (const char *)
 
static __inline const PObjectPTraceObjectInstance (const PObject *obj)
 
template<typename T >
static Comparison Compare2 (T v1, T v2)
 Compare two types, returning Comparison type. More...
 
static Comparison InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
 Internal function caled from CompareObjectMemoryDirect() More...
 

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.

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 ( const void *  sessionId,
PINDEX  idSize 
)
protected
Method PSSLContext::GetMethod ( ) const
inline

References m_method.

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   
)
PSSLContext::P_DECLARE_TRACED_ENUM ( Method  ,
SSLv23  ,
SSLv3  ,
TLSv1  ,
TLSv1_1  ,
TLSv1_2  ,
DTLSv1  ,
DTLSv1_2  ,
DTLSv1_2_v1_0   
)
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.
bool PSSLContext::SetExtension ( const char *  extension)

Set TLS extension.

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::SetVerifyDirectory ( const PDirectory caDir)

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

Parameters
caDirDirectory for CA certificates
bool PSSLContext::SetVerifyFile ( const PFilePath caFile)

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

Parameters
caFileFile for CA 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::SetVerifySystemDefault ( )

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

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

const Method PSSLContext::HighestDTLS = DTLSv1_2_v1_0
static
const Method PSSLContext::HighestTLS = TLSv1_2
static
ssl_ctx_st* PSSLContext::m_context
protected

Referenced by operator ssl_ctx_st *().

Method PSSLContext::m_method
protected

Referenced by GetMethod().

PSSLPasswordNotifier PSSLContext::m_passwordNotifier
protected

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