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 newOCSP_CERTIDstructure and hands it back, using the message digestdgstfor the certificatesubjectwith theissuerissuer. And ifdgstisNULL? No stress, it just uses SHA1 instead. Iconic behaviour, honestly.OCSP_cert_id_new()β also builds and returns a freshOCSP_CERTID, but this time out ofdgst, the issuer nameissuerName, the issuer key hashissuerKey, and the serial numberserialNumber. DIY energy β¨OCSP_CERTID_free()β frees upid. And if the argument isNULL? It literally does nothing. Zero drama, we love that for us. πOCSP_id_cmp()β comparesOCSP_CERTIDaandb. The full vibe check. π₯OCSP_id_issuer_cmp()β compares only the issuer name ofOCSP_CERTIDaandb. Partial match, main character focus. πOCSP_id_get0_info()β returns the issuer name hash, hash OID, issuer key hash and serial number contained incid. And if you don't need some of those values? Just set the corresponding parameter toNULL, bestie. Choose your own adventure. π
β RETURN VALUES β
OCSP_cert_to_id()andOCSP_cert_id_new()return either a pointer to a validOCSP_CERTIDstructure, orNULLif an error occurred. Fingers crossed for the first one π€OCSP_id_cmp()andOCSP_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 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. 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 π
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
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms