OCSP_CERT_TO_ID(3ossl)

πŸ’– OCSP_CERT_TO_ID πŸ’– (that's the 3ossl manual, bestie)

okay so bestie, gather round, because today we're talking about the OpenSSL OCSP certificate ID utility functions ✨ β€” the little squad that builds and compares OCSP_CERTID structures. It's giving certificate-identifier-core and honestly? obsessed. πŸŽ€


✨ 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, aka your new faves 🫢


🌸 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 tea on each one β˜•

  • OCSP_cert_to_id() β€” makes you a brand new OCSP_CERTID structure and hands it back, using the message digest dgst for the certificate subject with the issuer issuer. And if dgst is NULL? No stress, it just uses SHA1 instead. Iconic behaviour, honestly.
  • OCSP_cert_id_new() β€” also builds and returns a fresh OCSP_CERTID, but this time out of dgst, the issuer name issuerName, the issuer key hash issuerKey, and the serial number serialNumber. DIY energy ✨
  • OCSP_CERTID_free() β€” frees up id. And if the argument is NULL? It literally does nothing. Zero drama, we love that for us. πŸ’€
  • OCSP_id_cmp() β€” compares OCSP_CERTID a and b. The full vibe check. πŸ”₯
  • OCSP_id_issuer_cmp() β€” compares only the issuer name of OCSP_CERTID a and b. Partial match, main character focus. πŸ‘‘
  • OCSP_id_get0_info() β€” returns the issuer name hash, hash OID, issuer key hash and serial number contained in cid. And if you don't need some of those values? Just set the corresponding parameter to NULL, bestie. Choose your own adventure. 🌈

⭐ 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. Fingers crossed for the first one 🀞
  • OCSP_id_cmp() and OCSP_id_issuer_cmp() return zero for a match and nonzero otherwise. Yes, zero means "yes" β€” it's giving chaotic but we deal. 😭
  • OCSP_CERTID_free() does not return a value. It simply does its thing and leaves. Silent queen. πŸŽ€
  • OCSP_id_get0_info() returns 1 for success and 0 for failure. Binary baddie. πŸ’…

πŸ¦‹ NOTES πŸ¦‹

Real talk: OCSP clients will typically only use OCSP_cert_to_id() or OCSP_cert_id_new(). The other functions are the ones used by responder applications. So if you're the client, you're chilling with just two of these. 😌

⚠️ MAJOR CAVEAT, do not skip this: 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. Do not free them yourself. Do not pass go. Do not collect $200. πŸ™ˆ

πŸ”₯ 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)


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 whole page, bestie 🫢 this was OpenSSL 3.5.9, dated 2026-09-29, and yeah the manual name is OCSP_CERT_TO_ID(3ossl) in case the title didn't already make it obvious πŸ’– stay certified, stay identified, mwah 😘✨

πŸ“¦ where this page comes from