libdcp
|
A chain of any number of certificates, from root to leaf. More...
#include <certificate_chain.h>
Public Types | |
typedef std::vector< Certificate > | List |
Public Member Functions | |
CertificateChain (boost::filesystem::path openssl, int validity_in_days, std::string organisation="example.org", std::string organisational_unit="example.org", std::string root_common_name=".smpte-430-2.ROOT.NOT_FOR_PRODUCTION", std::string intermediate_common_name=".smpte-430-2.INTERMEDIATE.NOT_FOR_PRODUCTION", std::string leaf_common_name="CS.smpte-430-2.LEAF.NOT_FOR_PRODUCTION") | |
CertificateChain (std::string s) | |
void | add (Certificate c) |
void | remove (Certificate c) |
void | remove (int i) |
Certificate | root () const |
Certificate | leaf () const |
List | leaf_to_root () const |
List | root_to_leaf () const |
List | unordered () const |
bool | valid (std::string *reason=nullptr) const |
bool | chain_valid () const |
bool | private_key_valid () const |
void | sign (xmlpp::Element *parent, Standard standard) const |
void | add_signature_value (xmlpp::Element *parent, std::string ns, bool add_indentation) const |
boost::optional< std::string > | key () const |
void | set_key (std::string k) |
std::string | chain () const |
Private Member Functions | |
bool | chain_valid (List const &chain, std::string *error=nullptr) const |
Private Attributes | |
List | _certificates |
boost::optional< std::string > | _key |
A chain of any number of certificates, from root to leaf.
A CertificateChain object can also (optionally) hold the private key corresponding to the leaf certificate.
Definition at line 74 of file certificate_chain.h.
CertificateChain::CertificateChain | ( | boost::filesystem::path | openssl, |
int | validity_in_days, | ||
std::string | organisation = "example.org" , |
||
std::string | organisational_unit = "example.org" , |
||
std::string | root_common_name = ".smpte-430-2.ROOT.NOT_FOR_PRODUCTION" , |
||
std::string | intermediate_common_name = ".smpte-430-2.INTERMEDIATE.NOT_FOR_PRODUCTION" , |
||
std::string | leaf_common_name = "CS.smpte-430-2.LEAF.NOT_FOR_PRODUCTION" |
||
) |
Create a chain of certificates for signing things.
openssl | Name of openssl binary (if it is on the path) or full path. |
Definition at line 201 of file certificate_chain.cc.
|
explicit |
Read a CertificateChain from a string.
s | A string containing one or more PEM-encoded certificates. |
Definition at line 354 of file certificate_chain.cc.
void CertificateChain::add | ( | Certificate | c | ) |
Add a certificate to the chain.
c | Certificate to add. |
Definition at line 405 of file certificate_chain.cc.
void CertificateChain::add_signature_value | ( | xmlpp::Element * | parent, |
std::string | ns, | ||
bool | add_indentation | ||
) | const |
Sign an XML node.
parent | Node to sign. |
ns | Namespace to use for the signature XML nodes. |
Definition at line 655 of file certificate_chain.cc.
bool CertificateChain::chain_valid | ( | ) | const |
Check to see if the chain is valid (i.e. root signs the intermediate, intermediate signs the leaf and so on) and that the private key (if there is one) matches the leaf certificate.
Definition at line 437 of file certificate_chain.cc.
|
private |
error | if non-null, filled with an error if a certificate in the list has a a problem. |
Definition at line 449 of file certificate_chain.cc.
Certificate CertificateChain::leaf | ( | ) | const |
Definition at line 381 of file certificate_chain.cc.
CertificateChain::List CertificateChain::leaf_to_root | ( | ) | const |
Definition at line 389 of file certificate_chain.cc.
bool CertificateChain::private_key_valid | ( | ) | const |
Check that there is a valid private key for the leaf certificate. Will return true if there are no certificates.
Definition at line 524 of file certificate_chain.cc.
void CertificateChain::remove | ( | Certificate | c | ) |
Remove a certificate from the chain.
c | Certificate to remove. |
Definition at line 412 of file certificate_chain.cc.
void CertificateChain::remove | ( | int | i | ) |
Remove the i'th certificate in the chain, as listed from root to leaf.
Definition at line 422 of file certificate_chain.cc.
Certificate CertificateChain::root | ( | ) | const |
Definition at line 373 of file certificate_chain.cc.
CertificateChain::List CertificateChain::root_to_leaf | ( | ) | const |
Definition at line 588 of file certificate_chain.cc.
void CertificateChain::sign | ( | xmlpp::Element * | parent, |
Standard | standard | ||
) | const |
Add a <Signer> and <ds:Signature> nodes to an XML node.
parent | XML node to add to. |
standard | INTEROP or SMPTE. |
Definition at line 604 of file certificate_chain.cc.
bool CertificateChain::valid | ( | std::string * | reason = nullptr | ) | const |
Check if the certificates form a chain (i.e. root signs intermediate etc.) and that the private key matches the leaf certificate.
if | not nullptr, filled in with a reason for vailure (or untouched if there is no error) |
Definition at line 565 of file certificate_chain.cc.
|
private |
Our certificates, not in any particular order
Definition at line 187 of file certificate_chain.h.
|
private |
Leaf certificate's private key, if known, in PEM format
Definition at line 189 of file certificate_chain.h.