X509_CMP(3)
π X509_CMP(3): comparing X.509 certificates and related values π
okay so bestie, this is the X509_CMP(3) page from the libcrypto library β yes, the one with all the comparison girlies. Itβs giving βsame or not same?β energy, and every function here is doing a very specific little compare. π«Ά
β¨ NAME β¨
X509_cmp, X509_NAME_cmp, X509_issuer_and_serial_cmp, X509_issuer_name_cmp, X509_subject_name_cmp, X509_CRL_cmp, X509_CRL_match β compare X.509 certificates and related values.
π SYNOPSIS π
library βlibcryptoβ #include <openssl/x509.h>
int
X509_cmp(const X509 *a, const X509 *b);
int
X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b);
int
X509_issuer_and_serial_cmp(const X509 *a, const X509 *b);
int
X509_issuer_name_cmp(const X509 *a, const X509 *b);
int
X509_subject_name_cmp(const X509 *a, const X509 *b);
int
X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b);
int
X509_CRL_match(const X509_CRL *a, const X509_CRL *b);
πΈ DESCRIPTION πΈ
X509_cmp()β compares two X.509 certificates usingmemcmp(3)on the hashes of their canonical (DER) representations as generated withX509_digest(3). The digest function is implementation-specific: LibreSSL usesSHA-512, other implementations useSHA-1.X509_NAME_cmp()β compares two X.501 Name objects using their canonical (DER) representations generated withi2d_X509_NAME(3).X509_issuer_and_serial_cmp()β compares theissuerandserialNumberfields of twoTBSCertificatestructures, usingX509_NAME_cmp()for the issuer fields.X509_issuer_name_cmp()β compares theissuerfields of twoTBSCertificatestructures usingX509_NAME_cmp().X509_subject_name_cmp()β compares thesubjectfields of twoTBSCertificatestructures usingX509_NAME_cmp().X509_CRL_cmp()β is misnamed; it only compares theissuerfields of twoTBSCertListstructures usingX509_NAME_cmp(). the name is lowkey a lie, bestie πX509_CRL_match()β compares two certificate revocation lists usingmemcmp(3)on the hashes of their canonical (DER) representations as generated withX509_CRL_digest(3). The digest function is implementation-specific: LibreSSL usesSHA-512, other implementations useSHA-1.
π RETURN VALUES π
All these functions return 0 to indicate a match or a non-zero value to indicate a mismatch. slay, very simple β¨
X509_NAME_cmp(), X509_issuer_and_serial_cmp(), X509_issuer_name_cmp(), X509_subject_name_cmp() and X509_CRL_cmp() may return -2 to indicate an error. noted, bestie π«‘
π₯ SEE ALSO π₯
π STANDARDS π
RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile
- section 4.1: Basic Certificate Fields
- section 5.1: CRL Fields
π¦ HISTORY π¦
X509_issuer_and_serial_cmp(),X509_issuer_name_cmp(), andX509_subject_name_cmp()first appeared in SSLeay 0.5.1 andX509_NAME_cmp()andX509_CRL_cmp()in SSLeay 0.8.0. These functions have been available since OpenBSD 2.4.X509_cmp()first appeared in OpenSSL 0.9.5 and has been available since OpenBSD 2.7.X509_CRL_match()first appeared in OpenSSL 1.0.0 and has been available since OpenBSD 4.9.
π BUGS π
For X509_NAME_cmp(), X509_issuer_and_serial_cmp(), X509_issuer_name_cmp(), X509_subject_name_cmp() and X509_CRL_cmp(), the return value -2 sometimes indicates a mismatch and sometimes an error. so yeah, -2 is wearing two hats and that is a little cursed π
mwah π β this page is from Debian, dated June 8, 2025. periodt β¨
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2019 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms