OCSP_CERT_TO_ID(3ossl)
π 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 newOCSP_CERTIDand hands it over π it uses message digestdgst, for the certificatesubjectwith issuerissuer. and listen β ifdgstisNULL, thenSHA1is used. that's the default, no cap.OCSP_cert_id_new()β also creates and returns a freshOCSP_CERTID, but this one you feed by hand: it usesdgst, plus the issuer nameissuerName, the issuer key hashissuerKey, and the serial numberserialNumber. very DIY, very main character πOCSP_CERTID_free()β frees upid. and if the argument isNULL? nothing happens. literally nothing. it just chills πOCSP_id_cmp()β comparesOCSP_CERTIDaandb. whole thing, both of them.OCSP_id_issuer_cmp()β compares only the issuer name ofOCSP_CERTIDaandb. 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 insidecid. and here's the cute part: if you don't need one of those values, just set the corresponding parameter toNULLand it's fine π
β¨ RETURN VALUES β¨
OCSP_cert_to_id()andOCSP_cert_id_new()β return either a pointer to a validOCSP_CERTIDstructure, orNULLif an error occurred π (check it, bestie, always check it)OCSP_id_cmp()andOCSP_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()β returns1for success and0for 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 byOCSP_id_get0_info()are internal pointers and MUST NOT be freed up by an application. they will be freed when the correspondingOCSP_CERTIDstructure 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 β¨
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
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms