X509_FIND_BY_SUBJECT(3)

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

πŸ’… X509_FIND_BY_SUBJECT(3) πŸ’…

ok so bestie, this is a page from the Library Functions Manual for a couple of cert-hunting functions in libcrypto. No preamble needed, we're jumping straight in 🫢


✨ NAME ✨

X509_find_by_subject, X509_find_by_issuer_and_serial β€” search an array of X.509 certificates πŸ”πŸŽ€


🌸 SYNOPSIS 🌸

First thing's first, you gotta link the library and pull in the header, like:

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

Then, the two icons themselves:

X509 *
X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *subject);

X509 *
X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *issuer,
    ASN1_INTEGER *serial);

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so picture this: you've got a whole variable-sized array sk full of certificates, and you need one of them. That's literally the whole plot πŸ’€

  • X509_find_by_subject() β€” it goes through sk looking for a certificate whose subject name matches. That's it, that's the mission. subject match = found bestie πŸ’–
  • X509_find_by_issuer_and_serial() β€” this one's pickier. It searches the array for a certificate where both the issuer name and the serial number match the arguments. Two boxes to tick, no shortcuts ✨

πŸ‘‘ RETURN VALUES πŸ‘‘

Both of these cuties return a pointer to the first matching certificate β€” first one wins, no queue-jumping πŸŽ€

And if sk is NULL? Or the array just doesn't have a match? You get NULL back. That's the whole vibe check. 😭


🌈 SEE ALSO 🌈

Go read these next, iykyk:


⭐ HISTORY ⭐

These functions first appeared in SSLeay 0.8.1 and have been available since OpenBSD 2.4. absolute elders, we respect them πŸ«‘πŸ’œ


and that's the page!! mwah πŸ’‹ this one's from Debian, dated June 8, 2025 β€” ty for reading, go find those certificates bestie πŸ§šβ€β™€οΈπŸŽ€πŸ’–

πŸ“¦ where this page comes from