std1.0.0-beta-7 SafeC docs

std :: crypto::x509

Struct std::X509Cert

#include <std/crypto/x509.h> source

struct X509Cert {
    struct X509Name subject;
    struct X509Name issuer;
    struct X509Validity validity;
    struct X509San san;
    unsigned char pubkey[X509_KEY_LEN];
    unsigned long pubkey_len;
    unsigned char serial[20];
    unsigned long serial_len;
    int is_ca;
    int key_usage;
}

Parsed certificate (all fields, no dynamic allocation).

Fields

§struct X509Name subjectsource
§struct X509Name issuersource
§struct X509Validity validitysource
§struct X509San sansource
§unsigned char pubkey[X509_KEY_LEN]source
§unsigned long pubkey_lensource
§unsigned char serial[20]source
§unsigned long serial_lensource
§int is_casource

1 if BasicConstraints CA=TRUE

§int key_usagesource

raw KeyUsage bits

Methods

§int is_valid_at(unsigned long long ts) constsource · definition

Is the certificate currently valid for the given Unix timestamp?

§int matches_hostname(const &char hostname) constsource · definition

Does hostname match a DNS Subject Alternative Name (or, only when the certificate has none, the subject CN)? Case-insensitive; '*.' wildcards match one leftmost label.

§int is_ca_cert() constsource · definition

Is this a CA certificate?

§int init([]const unsigned char der_ref)source · definition

Parse a DER-encoded certificate from der (len bytes) into this struct in place (zeroed first). Returns 0 on success, negative on error.

§int verify_chain(const &X509Cert issuer_cert) constsource · definition

Does this certificate's issuer name match issuer_cert's subject? A structural check only: X509Cert keeps no signature. Verify signatures with X509Parsed and x509_verify_signed_by() below (std/tls builds and verifies whole chains with them).