Ssl::ValidatorList Class Reference

Performs certificate validation. More...

#include <ValidatorList.h>

Inheritance diagram for Ssl::ValidatorList:
Collaboration diagram for Ssl::ValidatorList:

Public Member Functions

bool add (Validator *validator)
 Add a validator to the list. More...
 
template<class T >
bool pin (const T &fingerprint)
 Pin a fingerprint. More...
 
bool add (ValidatorCallback callback, void *data=nullptr)
 Register a custom validator callback. More...
 
bool validate (const Certificate *certificate)
 Validate certificate via registered validators. More...
 
- Public Member Functions inherited from Vector< Validator >
 Vector (unsigned int initialCapacity=10, unsigned int capacityIncrement=10)
 
 Vector (const Vector &rhv)
 
 Vector (Vector &&)=delete
 
 ~Vector ()
 
unsigned int capacity () const
 
bool contains (const T &elem) const
 
const Validator & firstElement () const
 
int indexOf (const T &elem) const
 
bool isEmpty () const
 
const Validator & lastElement () const
 
int lastIndexOf (const T &elem) const
 
unsigned int count () const override
 
unsigned int size () const
 
void copyInto (Validator *array) const
 
bool add (const Validator &obj)
 
bool addElement (const Validator &obj)
 
bool addElement (Validator *objp)
 
void clear ()
 
bool ensureCapacity (unsigned int minCapacity)
 
void removeAllElements ()
 
bool removeElement (const T &elem)
 
bool setSize (unsigned int newSize)
 Reduce or increase number of items. More...
 
void trimToSize ()
 Reduce capacity to match current size. More...
 
const Validator & elementAt (unsigned int index) const
 
bool insertElementAt (const Validator &obj, unsigned int index)
 
bool remove (unsigned int index)
 
bool removeElementAt (unsigned int index)
 
bool setElementAt (const Validator &obj, unsigned int index)
 
const Validator & get (unsigned int index) const
 
const Validator & operator[] (unsigned int index) const override
 
Validator & operator[] (unsigned int index) override
 
Vector< Validator > & operator= (const Vector< Validator > &rhv)
 
Vector< Validator > & operator= (Vector< Validator > &&other) noexcept
 
void sort (Comparer compareFunction)
 
Iterator< false > begin ()
 
const Iterator< true > begin () const
 
Iterator< false > end ()
 
const Iterator< true > end () const
 
- Public Member Functions inherited from Countable< Validator >
 Countable ()
 
 Countable (const Countable &)=delete
 
 Countable (Countable &&)=delete
 
Countableoperator= (const Countable &)=delete
 
Countableoperator= (Countable &&)=delete
 
virtual ~Countable ()
 
const Validator & at (unsigned int i) const
 

Public Attributes

Fingerprint::Types fingerprintTypes
 Contains a list of registered fingerprint types. More...
 

Additional Inherited Members

- Public Types inherited from Vector< Validator >
using Comparer = int(*)(const Validator &lhs, const Validator &rhs)
 
- Protected Types inherited from Vector< Validator >
using ElementList = wiring_private::List< Validator >
 
- Protected Member Functions inherited from Vector< Validator >
void copyFrom (const Vector &rhv)
 
- Protected Attributes inherited from Vector< Validator >
unsigned int _size
 
unsigned int _increment
 
ElementList _data
 

Detailed Description

Performs certificate validation.

Validators are created in the application's session initialisation callback. When the certificate has been received, it is checked against each registered validator in turn until successful. All validators are destroyed during this process.

If there are no validators in the list then the certificate will not be checked and the connection accepted.

Member Function Documentation

◆ add() [1/2]

bool Ssl::ValidatorList::add ( Validator validator)
inline

Add a validator to the list.

Parameters
validatorMust be allocated on the heap

◆ add() [2/2]

bool Ssl::ValidatorList::add ( ValidatorCallback  callback,
void *  data = nullptr 
)
inline

Register a custom validator callback.

Parameters
callback
dataUser-provided data (optional)

◆ pin()

template<class T >
bool Ssl::ValidatorList::pin ( const T &  fingerprint)
inline

Pin a fingerprint.

Creates and adds a fingerprint validator to the list

◆ validate()

bool Ssl::ValidatorList::validate ( const Certificate certificate)

Validate certificate via registered validators.

Parameters
certificateWhen called with nullptr will free all validators, then fail
Return values
booltrue on success, false on failure
Note
Called by SSL framework.

We only need one match for a successful result, but we free all the validators. This method must be called no more than ONCE.

Member Data Documentation

◆ fingerprintTypes

Fingerprint::Types Ssl::ValidatorList::fingerprintTypes

Contains a list of registered fingerprint types.

Allows implementations to avoid calculating fingerprint values which are not required, as this is computationally expensive.


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