Skip to content

SCertEntry

Jay edited this page Oct 3, 2026 · 2 revisions

SCertEntry

#include <certpp/x509/chain.hpp> --- certpp::x509

One certificate in a CCertCollection, with the things a PKCS#12 container stores alongside it.

The private key is optional because a collection usually holds a mixture: one end-entity certificate whose key the holder has, and the CA certificates above it, whose keys the holder emphatically does not. friendlyName and localKeyId are PKCS#9 attributes (1.2.840.113549.1.9.20 and .21) that PKCS#12 carries on its bags; localKeyId is how a PFX pairs a certificate bag with its key bag, so a collection that is going to become a PFX needs somewhere to keep it even before the container itself exists.

Fields

  • CCert cert --- The certificate.
  • crypto::IPrivateKeyPtr privateKey --- The matching private key, or null when the collection holds only the certificate.
  • CString friendlyName --- The PKCS#9 friendlyName attribute, or empty if there is none.
  • COctet localKeyId --- The PKCS#9 localKeyId attribute, or empty if there is none.

Methods

SCertEntry()

Constructs an empty entry.

inline bool hasPrivateKey() const

Reports whether this entry carries a private key.

Returns: True if a private key is present.

Example

One entry read out of a collection. A collection normally holds a mixture -- the end-entity certificate with its key, the CA certificates above it without -- so hasPrivateKey() is the test, and checkKeyPairing() is what establishes the key really is that certificate's.

// given: const CCertCollection& col, size_t index
SCertEntry entry;
if (col.at(index, entry) != ERET_OK) {
    return; // index was at or beyond col.count()
}

if (!entry.hasPrivateKey()) {
    return; // a CA certificate in the chain, not the entry holding the key
}

// add() does not check the two against each other, because this costs a signature operation.
if (col.checkKeyPairing(index) != ERET_OK) {
    return; // ERET_KEY_ERROR: the key does not actually belong to entry.cert
}
// entry.friendlyName/entry.localKeyId are the PKCS#9 attributes a PFX pairs bags with

Reference generated from certpp/x509/chain.hpp at commit 0834b29 (v1.0.1). The header is authoritative --- if this page disagrees with it, the header is right and this page needs regenerating.

Clone this wiki locally