CertificateStore Class Reference

#include <Pt/Ssl/CertificateStore.h>

Store for X509 certificates and their keys. More...

Classes

class  ConstIterator
 Iterator to a certificate in the store. More...

Public Member Functions

 CertificateStore ()
 Creates an empty certificate store.
 ~CertificateStore ()
 Destroys the store and its certificates.
void loadPkcs12 (std::istream &is, const char *passwd)
 Loads PKCS12 certificates and keys from is.
void loadPkcs12 (const char *data, std::size_t len, const char *passwd)
 Loads PKCS12 certificates and keys from memory.
void loadPem (const char *data, std::size_t len, const char *passwd)
 Loads PEM certificates and keys from memory.
const CertificatefindCertificate (const std::string &subject)
 Returns a certificate whose subject contains subject.
const CertificategetCertificate (const std::string &subject)
 Returns a certificate whose subject contains subject.
std::size_t size () const
 Returns the number of certificates in the store.
ConstIterator begin () const
 Returns an iterator to the first certificate.
ConstIterator end () const
 Returns an iterator to one past the last certificate.

Detailed Description

CertificateStore is the owner of the certificates the group described. PKCS12 data is loaded from an iostream or from a memory buffer, and PEM data is loaded from memory. Each load adds to the store; it does not replace certificates already loaded. Unreadable PKCS12 or PEM data throws InvalidCertificate.

findCertificate() searches for a subject substring and returns a pointer the store still owns, or a null pointer. getCertificate() is the same search and throws InvalidCertificate when nothing matches. size(), begin() and end() inspect the current contents.

A Certificate reference or pointer from this store is valid only while the store exists and still holds that certificate.

Member Function Documentation

◆ loadPkcs12() [1/2]

void loadPkcs12 ( std::istream & is,
const char * passwd )
Exceptions
%InvalidCertificateif the PKCS12 data is invalid.

◆ loadPkcs12() [2/2]

void loadPkcs12 ( const char * data,
std::size_t len,
const char * passwd )
Exceptions
%InvalidCertificateif the PKCS12 data is invalid.

◆ loadPem()

void loadPem ( const char * data,
std::size_t len,
const char * passwd )
Exceptions
%InvalidCertificateif the PEM data is invalid.

◆ findCertificate()

const Certificate * findCertificate ( const std::string & subject)

Returns a null pointer if no certificate was found.

◆ getCertificate()

const Certificate & getCertificate ( const std::string & subject)
Exceptions
%InvalidCertificateif no certificate was found.