OCSP_CERT_TO_ID(3)

πŸ“¦ version 4.4.0, in alpine 3.24, arch rolling

Welcome to the OCSP_CERT_TO_ID(3) page, bestie πŸ’… β€” this is the Library Functions Manual, and we’re about to get into the OCSP certificate ID utility functions πŸŽ€

✨ NAME ✨

okay so this page covers the whole little squad: OCSP_CERTID_new, OCSP_CERTID_free, OCSP_cert_to_id, OCSP_cert_id_new, OCSP_id_issuer_cmp, OCSP_id_cmp, and OCSP_id_get0_info β€” the OCSP certificate ID utility functions πŸ’–

🌸 SYNOPSIS 🌸

First up, the library/include situation:

library β€œlibcrypto” #include <openssl/ocsp.h>

And here are the prototypes, copied exactly because we do not mess with signatures, periodt:

OCSP_CERTID *
OCSP_CERTID_new(void);

void
OCSP_CERTID_free(OCSP_CERTID *id);

OCSP_CERTID *
OCSP_cert_to_id(const EVP_MD *dgst, const X509 *subject,
    const X509 *issuer);

OCSP_CERTID *
OCSP_cert_id_new(const EVP_MD *dgst, const X509_NAME *issuerName,
    const ASN1_BIT_STRING *issuerKey, const ASN1_INTEGER *serialNumber);

int
OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b);

int
OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b);

int
OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd,
    ASN1_OCTET_STRING **pikeyHash, ASN1_INTEGER **pserial,
    OCSP_CERTID *cid);

πŸ¦‹ DESCRIPTION πŸ¦‹

OCSP_CERTID_new() allocates and initializes an empty OCSP_CERTID object, and that object represents an ASN.1 CertID structure defined in RFC 6960. It can store hashes of an issuer’s distinguished name and public key together with a serial number of a certificate. It is used by the OCSP_ONEREQ object described in OCSP_ONEREQ_new(3) and by the OCSP_SINGLERESP object described in OCSP_SINGLERESP_new(3). OCSP_CERTID_free() frees id. 🫢

  • OCSP_cert_to_id() β€” creates and returns a new OCSP_CERTID object using message digest dgst for certificate subject with issuer issuer. If dgst is NULL, then SHA-1 is used. ✨
  • OCSP_cert_id_new() β€” creates and returns a new OCSP_CERTID using dgst and issuer name issuerName, issuer key hash issuerKey, and serial number serialNumber. 🌸
  • OCSP_id_issuer_cmp() β€” compares the hash algorithms, the hashed issuer distinguished names, and the hashed public keys of OCSP_CERTID a and b. πŸ”
  • OCSP_id_cmp() β€” compares OCSP_CERTID a and b using OCSP_id_issuer_cmp() followed by a comparison of the certificate serial numbers with ASN1_INTEGER_cmp(3). πŸ’…
  • OCSP_id_get0_info() β€” returns the issuer name hash, hash OID, issuer key hash, and serial number contained in cid. If any of the values are not required, the corresponding parameter can be set to NULL. The values returned by OCSP_id_get0_info() are internal pointers and must not be freed up by an application: they will be freed when the corresponding OCSP_CERTID object is freed. 🚨

OCSP clients will typically only use OCSP_cert_to_id() or OCSP_cert_id_new(): the other functions are used by responder applications. iykyk 🧚

πŸ’– RETURN VALUES πŸ’–

  • OCSP_CERTID_new(), OCSP_cert_to_id(), and OCSP_cert_id_new() return either a pointer to a valid OCSP_CERTID object or NULL if an error occurred. 😭
  • OCSP_id_cmp() and OCSP_id_issuer_cmp() return 0 for a match or non-zero otherwise. πŸ‘‘
  • OCSP_id_get0_info() returns 1 for success or 0 for failure. ⭐

πŸ”₯ SEE ALSO πŸ”₯

go read these next, bestie:

🌈 STANDARDS 🌈

RFC 6960: X.509 Internet Public Key Infrastructure Online Certificate Status Protocol, section 4: Details of the Protocol

⭐ HISTORY ⭐

These functions first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2. iconic behavior, honestly πŸ‘‘


xoxo, signing off from Debian on June 8, 2025 πŸ’–πŸ«Ά

πŸ“¦ where this page comes from