OCSP_CERT_TO_ID(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… OCSP_CERT_TO_ID(3ossl) β€” bestie's guide to OCSP cert ID stuff

okay so this is an OpenSSL manpage (yes, the 3ossl fam πŸŽ€) and it's all about the certificate ID utility functions for OCSP β€” you know, the little fingerprint-ish thing that says "yes this is that cert, for real". sit down, grab a strawberry drink πŸ“, we're getting into it.


✨ NAME ✨

OCSP_cert_to_id, OCSP_cert_id_new, OCSP_CERTID_free, OCSP_id_issuer_cmp, OCSP_id_cmp, OCSP_id_get0_info β€” the OCSP certificate ID utility functions. that's the whole squad 🫢


✨ SYNOPSIS ✨

#include <openssl/ocsp.h>

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

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

void OCSP_CERTID_free(OCSP_CERTID *id);

int OCSP_id_issuer_cmp(const OCSP_CERTID *a, const OCSP_CERTID *b);
int OCSP_id_cmp(const OCSP_CERTID *a, const 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 ✨

so here's the vibe, function by function πŸ‘‘

  • OCSP_cert_to_id() β€” builds you a brand new OCSP_CERTID and hands it over πŸ’– it uses message digest dgst, for the certificate subject with issuer issuer. and listen β€” if dgst is NULL, then SHA1 is used. that's the default, no cap.
  • OCSP_cert_id_new() β€” also creates and returns a fresh OCSP_CERTID, but this one you feed by hand: it uses dgst, plus the issuer name issuerName, the issuer key hash issuerKey, and the serial number serialNumber. very DIY, very main character πŸŽ€
  • OCSP_CERTID_free() β€” frees up id. and if the argument is NULL? nothing happens. literally nothing. it just chills 😌
  • OCSP_id_cmp() β€” compares OCSP_CERTID a and b. whole thing, both of them.
  • OCSP_id_issuer_cmp() β€” compares only the issuer name of OCSP_CERTID a and b. just the issuer name. that's it. selective, iconic πŸ’…
  • OCSP_id_get0_info() β€” gives you back the issuer name hash, hash OID, issuer key hash and serial number that live inside cid. and here's the cute part: if you don't need one of those values, just set the corresponding parameter to NULL and it's fine πŸ™ˆ

✨ RETURN VALUES ✨

  • OCSP_cert_to_id() and OCSP_cert_id_new() β€” return either a pointer to a valid OCSP_CERTID structure, or NULL if an error occurred 😭 (check it, bestie, always check it)
  • OCSP_id_cmp() and OCSP_id_issuer_cmp() β€” return zero for a match and nonzero otherwise. yes, zero means match. yes, that's the opposite of what your gut says. it's giving "0 == slay" ✨
  • OCSP_CERTID_free() β€” does not return a value. it's above that.
  • OCSP_id_get0_info() β€” returns 1 for success and 0 for failure πŸ”₯

✨ NOTES ✨

OCSP clients will typically only use OCSP_cert_to_id() or OCSP_cert_id_new() β€” the other functions are used by responder applications. so if you're on the client side, you're chilling with two of these and the rest are for the responder girlies 🧚

⚠️ important, fr fr: 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 structure is freed. so like... do not touch. do not free. hands off πŸ«ΆπŸ’€

✨ SEE ALSO ✨

crypto(7), OCSP_request_add1_nonce(3), OCSP_REQUEST_new(3), OCSP_resp_find_status(3), OCSP_response_status(3), OCSP_sendreq_new(3) 🌈 β€” go read those next, iykyk


Copyright 2015-2024 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the page!! 🌸 mwah, go build something secure. this was version 3.5.6, dated 2026-04-07, and it's the OCSP_CERT_TO_ID(3ossl) page β€” periodt πŸ’œπŸ¦‹

πŸ“¦ where this page comes from