X509_CMP(3SSL)
π X509_CMP β comparing certs and their little friends
okay bestie so this is a page from the OpenSSL manual, section 3SSL, and it's literally all about comparing X509 stuff. No cap.
β¨ NAME β¨
so the whole girl gang here is: X509_cmp, X509_NAME_cmp, X509_issuer_and_serial_cmp, X509_issuer_name_cmp, X509_subject_name_cmp, X509_CRL_cmp, X509_CRL_match β and their whole job is comparing X509 certificates and related values. π
πΈ SYNOPSIS πΈ
#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 π¦
so this little set of functions is what you use to compare X509 objects β X509 certificates, X509 CRL objects, and all the various values hanging out inside an X509 certificate. it's giving comparison, but make it cryptographic. β¨
X509_cmp()β compares two X509 objects, the ones you passed in asaandb. The comparison is based on thememcmpresult of the hash values of the two X509 objects AND the canonical (DER) encoding values. Two things at once, she's multifaceted. πX509_NAME_cmp()β compares two X509_NAME objects, passed asaandb, and either of them may beNULL(yes really,NULLis allowed, be free). The comparison is based on thememcmpresult of the canonical (DER) encoding values of the two objects, usingi2d_X509_NAME(3). This procedure adheres to the matching rules for Distinguished Names (DN) given in RFC 4517 section 4.2.15 and RFC 5280 section 7.1. In particular, the order of Relative Distinguished Names (RDNs) is relevant β so like, RDN order actually matters, periodt. On the other hand, if an RDN is multi-valued, i.e., it contains a set of AttributeValueAssertions (AVAs), its members are effectively not ordered. so inside a multi-valued RDN, the AVAs are chill and unordered, but the RDNs themselves? order counts. iykyk.X509_issuer_and_serial_cmp()β compares the serial number and issuer values in the given X509 objectsaandb. that's it, that's the whole vibe.X509_issuer_name_cmp(),X509_subject_name_cmp()andX509_CRL_cmp()β these are effectively wrappers of theX509_NAME_cmp()function. iconic behavior honestly. They compare issuer names and subject names of the objects, or issuers of X509_CRL objects, respectively.X509_CRL_match()β compares two X509_CRL objects. Unlike theX509_CRL_cmp()function, this one compares the whole CRL content instead of just the issuer name. she does the full deep dive, not just the surface. π₯
π RETURN VALUES π
The X509 comparison functions return -1, 0, or 1 if object a is found to be less than, to match, or be greater than object b, respectively. it's giving leaderboard energy.
X509_NAME_cmp(), X509_issuer_and_serial_cmp(), X509_issuer_name_cmp(), X509_subject_name_cmp(), X509_CRL_cmp(), and X509_CRL_match() may return -2 to indicate an error. β οΈ
π NOTES π
These functions in fact utilize the underlying memcmp of the C library to do the comparison job β classic, reliable, lowkey the moment. Data to be compared varies from DER encoding data, hash value or ASN1_STRING. The sign of the comparison can be used to order the objects but it does not have a special meaning in some cases. so like, the sign is useful for sorting, but don't read too much into it every time. π
bestie listen.X509_NAME_cmp()and its wrappers utilize the value-2to indicate errors in some circumstances, which could cause confusion for the applications. so like,-2is a thing, don't get got by it. π
π SEE ALSO π
π COPYRIGHT π
Copyright 2019-2022 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 version 4.0.3, dated 2026-09-29, from the X509_CMP(3SSL) manual. go forth and compare your certs responsibly πππ¦
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms