My Project 1.7.4
C++ Distributed Hash Table
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
dht::crypto::Certificate Struct Reference
Collaboration diagram for dht::crypto::Certificate:
Collaboration graph
[legend]

Public Types

enum class  NameType {
  UNKNOWN = 0 , RFC822 , DNS , URI ,
  IP
}
 

Public Member Functions

 Certificate (gnutls_x509_crt_t crt)
 
 Certificate (Certificate &&o) noexcept
 
 Certificate (const Blob &crt)
 
 Certificate (const std::string &pem)
 
 Certificate (const uint8_t *dat, size_t dat_size)
 
template<typename Iterator >
 Certificate (const Iterator &begin, const Iterator &end)
 
template<typename Iterator >
 Certificate (const std::vector< std::pair< Iterator, Iterator > > &certs)
 
Certificateoperator= (Certificate &&o) noexcept
 
void pack (Blob &b) const
 
void unpack (const uint8_t *dat, size_t dat_size)
 
Blob getPacked () const
 
template<typename Iterator >
void unpack (const Iterator &begin, const Iterator &end)
 
template<typename Iterator >
void unpack (const std::vector< std::pair< Iterator, Iterator > > &certs)
 
template<typename Packer >
void msgpack_pack (Packer &p) const
 
void msgpack_unpack (msgpack::object o)
 
 operator bool () const
 
PublicKey getPublicKey () const
 
InfoHash getId () const
 
PkId getLongId () const
 
std::string getName () const
 
std::string getUID () const
 
std::string getIssuerName () const
 
std::string getIssuerUID () const
 
std::vector< std::pair< NameType, std::string > > getAltNames () const
 
std::chrono::system_clock::time_point getActivation () const
 
std::chrono::system_clock::time_point getExpiration () const
 
bool isCA () const
 
std::string toString (bool chain=true) const
 
std::string print () const
 
void revoke (const PrivateKey &, const Certificate &)
 
std::vector< std::shared_ptr< RevocationList > > getRevocationLists () const
 
void addRevocationList (RevocationList &&)
 
void addRevocationList (std::shared_ptr< RevocationList >)
 
gnutls_x509_crt_t getCopy () const
 
std::vector< gnutls_x509_crt_t > getChain (bool copy=false) const
 
std::pair< std::vector< gnutls_x509_crt_t >, std::vector< gnutls_x509_crl_t > > getChainWithRevocations (bool copy=false) const
 

Static Public Member Functions

static Certificate generate (const PrivateKey &key, const std::string &name="dhtnode", Identity ca={}, bool is_ca=false)
 

Public Attributes

gnutls_x509_crt_t cert {}
 
std::shared_ptr< Certificateissuer {}
 

Detailed Description

Definition at line 249 of file crypto.h.

Member Enumeration Documentation

◆ NameType

enum class dht::crypto::Certificate::NameType
strong

Definition at line 385 of file crypto.h.

Constructor & Destructor Documentation

◆ Certificate() [1/8]

dht::crypto::Certificate::Certificate ( )
inline

Definition at line 250 of file crypto.h.

◆ Certificate() [2/8]

dht::crypto::Certificate::Certificate ( gnutls_x509_crt_t  crt)
inline

Take ownership of existing gnutls structure

Definition at line 255 of file crypto.h.

◆ Certificate() [3/8]

dht::crypto::Certificate::Certificate ( Certificate &&  o)
inlinenoexcept

Definition at line 257 of file crypto.h.

◆ Certificate() [4/8]

dht::crypto::Certificate::Certificate ( const Blob crt)

Import certificate (PEM or DER) or certificate chain (PEM), ordered from subject to issuer

◆ Certificate() [5/8]

dht::crypto::Certificate::Certificate ( const std::string &  pem)
inline

Definition at line 264 of file crypto.h.

◆ Certificate() [6/8]

dht::crypto::Certificate::Certificate ( const uint8_t *  dat,
size_t  dat_size 
)
inline

Definition at line 267 of file crypto.h.

◆ Certificate() [7/8]

template<typename Iterator >
dht::crypto::Certificate::Certificate ( const Iterator &  begin,
const Iterator &  end 
)
inline

Import certificate chain (PEM or DER), ordered from subject to issuer

Definition at line 276 of file crypto.h.

◆ Certificate() [8/8]

template<typename Iterator >
dht::crypto::Certificate::Certificate ( const std::vector< std::pair< Iterator, Iterator > > &  certs)
inline

Import certificate chain (PEM or DER), ordered from subject to issuer

Definition at line 285 of file crypto.h.

Member Function Documentation

◆ getAltNames()

std::vector< std::pair< NameType, std::string > > dht::crypto::Certificate::getAltNames ( ) const

Read certificate alternative names

◆ getChain()

std::vector< gnutls_x509_crt_t > dht::crypto::Certificate::getChain ( bool  copy = false) const
inline

Definition at line 424 of file crypto.h.

◆ getChainWithRevocations()

std::pair< std::vector< gnutls_x509_crt_t >, std::vector< gnutls_x509_crl_t > > dht::crypto::Certificate::getChainWithRevocations ( bool  copy = false) const
inline

Definition at line 438 of file crypto.h.

◆ getCopy()

gnutls_x509_crt_t dht::crypto::Certificate::getCopy ( ) const
inline

Definition at line 414 of file crypto.h.

◆ getId()

InfoHash dht::crypto::Certificate::getId ( ) const

Same as getPublicKey().getId()

◆ getIssuerName()

std::string dht::crypto::Certificate::getIssuerName ( ) const

Read certificate issuer Common Name (CN)

◆ getIssuerUID()

std::string dht::crypto::Certificate::getIssuerUID ( ) const

Read certificate issuer User ID (UID)

◆ getName()

std::string dht::crypto::Certificate::getName ( ) const

Read certificate Common Name (CN)

◆ getPacked()

Blob dht::crypto::Certificate::getPacked ( ) const
inline

Definition at line 294 of file crypto.h.

◆ getUID()

std::string dht::crypto::Certificate::getUID ( ) const

Read certificate User ID (UID)

◆ isCA()

bool dht::crypto::Certificate::isCA ( ) const

Returns true if the certificate is marked as a Certificate Authority and has necessary key usage flags to sign certificates.

◆ msgpack_pack()

template<typename Packer >
void dht::crypto::Certificate::msgpack_pack ( Packer &  p) const
inline

Definition at line 356 of file crypto.h.

◆ operator bool()

dht::crypto::Certificate::operator bool ( ) const
inlineexplicit

Definition at line 366 of file crypto.h.

◆ toString()

std::string dht::crypto::Certificate::toString ( bool  chain = true) const

PEM encoded certificate. If chain is true, the issuer chain will be included (default).

◆ unpack() [1/2]

template<typename Iterator >
void dht::crypto::Certificate::unpack ( const Iterator &  begin,
const Iterator &  end 
)
inline

Import certificate chain (PEM or DER). Certificates are not checked during import.

Iterator is the type of an iterator or pointer to gnutls_x509_crt_t or Blob instances to import, that should be ordered from subject to issuer.

Definition at line 309 of file crypto.h.

◆ unpack() [2/2]

template<typename Iterator >
void dht::crypto::Certificate::unpack ( const std::vector< std::pair< Iterator, Iterator > > &  certs)
inline

Import certificate chain (PEM or DER). Certificates are not checked during import.

Iterator is the type of an iterator or pointer to the bytes of the certificates to import.

Parameters
certslist of (begin, end) iterator pairs, pointing to the PEM or DER certificate data to import, that should be ordered from subject to issuer.

Definition at line 336 of file crypto.h.

Member Data Documentation

◆ cert

gnutls_x509_crt_t dht::crypto::Certificate::cert {}

Definition at line 453 of file crypto.h.

◆ issuer

std::shared_ptr<Certificate> dht::crypto::Certificate::issuer {}

Definition at line 454 of file crypto.h.


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