X509_CHECK_CA(3)
β¨ X509_CHECK_CA(3) β¨
okay bestie, welcome to the libcrypto girlies' corner of the manual β page 3, we're in the library functions section, and this one is short but SO important π
πΈ NAME πΈ
X509_check_ca β the lil vibe check that tells you whether a certificate is a CA certificate π
π¦ SYNOPSIS π¦
first up, it's the libcrypto library, and you pull in the header like this:
#include <openssl/x509v3.h>
int
X509_check_ca(X509 *cert);
that's it. one function, one pointer, no drama β¨
π DESCRIPTION π
so X509_check_ca() looks at the certificate you hand it and answers the question: is this a CA certificate? π
and "CA certificate" here means one specific thing β like, is it allowed to sign other certificates? that's the whole entire job. nothing else. no extra credit, no side quests π«Ά
π₯ RETURN VALUES π₯
if cert IS a CA certificate, you get a non-zero value back. if it's not, you get 0. periodt π
but wait, there's more β because the non-zero values aren't all the same, and they're actually giving very specific info about what kind of CA cert you're holding. here's the tea:
1β an X.509 v3 CA certificate with abasicConstraintsextension set toCA:TRUEπ the classic, the original, the main character3β a self-signed X.509 v1 certificate π«Ά old school and signing itself, we love a self-sufficient icon4β a certificate that has akeyUsageextension with the bitkeyCertSignset, but is missingbasicConstraintsπ no cap, it's doing the job without the paperwork5β a certificate with an outdated Netscape Certificate Type extension that says it's a CA certificate π vintage, deprecated, but still showing up to the function
β SEE ALSO β
the friend group, all on page 3, go say hi:
BASIC_CONSTRAINTS_new(3)EXTENDED_KEY_USAGE_new(3)X509_check_issued(3)X509_check_purpose(3)X509_EXTENSION_new(3)X509_new(3)X509_verify_cert(3)
π HISTORY π
X509_check_ca() first appeared in OpenSSL 0.9.7f, and it's been living rent-free on the scene since OpenBSD 3.8. a legacy icon fr fr π§
π BUGS π
okay so this is the part where you gotta pay attention, bestie, because this is a real gotcha π
if X509_check_ca() fails to cache X509v3 extension values, it may end up failing to recognize a CA certificate. like, it'll be wrong. not it.
the fix? an application should call X509_check_purpose(3) with a purpose argument of -1 β that makes sure the X509v3 extensions actually get cached β before calling X509_check_ca() π
lowkey do this. every time. your future self will thank you π«Ά
and that's the page!! brought to you by the libcrypto library functions manual, straight outta Debian, dated September 19, 2026 β mwah, slay, go forth and validate those CAs β¨ππ
π¦ where this page comes from
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2015, 2016 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