Skip to content

SCertRequestAttribute

Jay edited this page Oct 3, 2026 · 2 revisions

SCertRequestAttribute

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

One PKCS#10 Attribute (RFC 2986 4.1) out of a certification request's attributes [0] IMPLICIT Attributes field:

Attribute ::= SEQUENCE { type OBJECT IDENTIFIER, values SET OF ANY }

Deliberately holds values as raw bytes rather than modelling each attribute type: the one attribute that matters for certificate issuance is PKCS#9's extensionRequest, and CCertRequest already decodes that one into its own extension list (see CCertRequest::extensionOf()). Everything else -- challengePassword, unstructuredName, a vendor's own private arc -- is handed back verbatim for a caller that knows what it is.

The same struct is both what CCertRequest hands back and what CCertRequestBuilder takes, with values meaning exactly the same bytes in each direction, so a parsed attribute can be fed straight back into a builder without reshaping it.

Fields

  • CString oid
  • COctet values

Methods

SCertRequestAttribute() = default

Constructs an empty attribute.

SCertRequestAttribute(const CString& oid, const COctet& values)

Constructs an attribute from its type OID and raw values content.

  • oid --- The attribute's type OID, in dotted-decimal text.
  • values --- The content octets of the attribute's values SET.

Example

One PKCS#10 attribute, with values meaning the same bytes in both directions -- the content octets of the attribute's values SET, without that SET's own tag and length -- so an attribute read off one request goes straight into a builder for another.

// given: const CCertRequest& request, CCertRequestBuilder& builder
for (const SCertRequestAttribute& attr : request.attributes()) {
    if (attr.oid == CString(CCertRequest::OID_EXTENSION_REQUEST)) {
        // builder.extensions writes this attribute itself; a second copy is rejected
        continue;
    }
    builder.attributes.add(attr);
}

// A new attribute has the same shape: DER elements, not bare text. This is one UTF8String
// inside the values SET, which is how PKCS#9's unstructuredName is encoded.
const uint8_t unstructuredName[] = { 0x0c, 0x03, 'a', 'b', 'c' };
builder.attributes.add(SCertRequestAttribute(
    CString("1.2.840.113549.1.9.2"),
    COctet(unstructuredName, sizeof(unstructuredName))
));

Reference generated from certpp/x509/csr.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