X509_FIND_BY_SUBJECT(3) | Library Functions Manual | X509_FIND_BY_SUBJECT(3)

# NAME

`X509_find_by_subject`, `X509_find_by_issuer_and_serial` — search an array of X.509 certificates

# SYNOPSIS

library “libcrypto”
`#include <openssl/x509.h>`

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

`X509_find_by_subject`() searches the variable-sized array sk for a certificate with a matching subject name.

`X509_find_by_issuer_and_serial`() searches the array for a certificate where both the issuer name and the serial number match the arguments.

# RETURN VALUES

These functions return a pointer to the first matching certificate or `NULL` if sk is `NULL` or does not contain a matching certificate.

# SEE ALSO

ASN1_INTEGER_new(3), STACK_OF(3), X509_cmp(3), X509_get_serialNumber(3), X509_get_subject_name(3), X509_NAME_new(3), X509_new(3)

# HISTORY

These functions first appeared in SSLeay 0.8.1 and have been available since OpenBSD 2.4.

June 8, 2025 | Debian