LIBRESSL-X509_GET_EXTENSION_FLAGS(3)
π X509_GET_EXTENSION_FLAGS(3) π
okay bestie, welcome to the Library Functions Manual page for X509_GET_EXTENSION_FLAGS(3) β manual name folded in near the top like a little name tag π«Ά
πΈ NAME πΈ
X509_get_extension_flags, X509_get_key_usage, X509_get_extended_key_usage β retrieve certificate extension data, aka grab the receipts on cert extensions π
β¨ SYNOPSIS β¨
here's the exact signature situation, no cap:
library βlibcryptoβ #include <openssl/x509v3.h>
uint32_t
X509_get_extension_flags(X509 *x);
uint32_t
X509_get_key_usage(X509 *x);
uint32_t
X509_get_extended_key_usage(X509 *x);
π DESCRIPTION π
these functions pull info related to the commonly used certificate extensions. iconic behavior.
X509_get_extension_flags() retrieves general info about a certificate, and it returns one or more of these flags OR'ed together:
EXFLAG_V1β the cert is an obsolete version 1 certificate. vintage, but not in a cute way πEXFLAG_BCONSβ the cert contains a basic constraints extension.EXFLAG_CAβ the cert contains basic constraints and asserts the CA flag.EXFLAG_PROXYβ the cert is a valid proxy certificate. in LibreSSL this flag is never set, periodt.EXFLAG_SIβ the cert is self issued (that is, subject and issuer names match).EXFLAG_SSβ subject and issuer names match and extension values imply it is self signed.EXFLAG_FRESHESTβ the freshest CRL extension is present in the cert.EXFLAG_CRITICALβ the cert contains an unhandled critical extension.EXFLAG_INVALIDβ some certificate extension values are invalid or inconsistent, and the certificate should be rejected. this bit may also be raised after an out-of-memory error while processing theX509object, so it may not be related to the processed ASN1 object itself. scary but important πEXFLAG_INVALID_POLICYβ theNID_certificate_policiescertificate extension is invalid or inconsistent, and the cert should be rejected. same OOM caveat: this bit may also be raised after an out-of-memory error while processing theX509object, so it may not be related to the processed ASN1 object itself.EXFLAG_KUSAGEβ the cert contains a key usage extension. the value can be retrieved usingX509_get_key_usage().EXFLAG_XKUSAGEβ the cert contains an extended key usage extension. the value can be retrieved usingX509_get_extended_key_usage().
X509_get_key_usage() returns the value of the key usage extension. if key usage is present, it returns zero or more of these flags:
KU_DIGITAL_SIGNATUREKU_NON_REPUDIATIONKU_KEY_ENCIPHERMENTKU_DATA_ENCIPHERMENTKU_KEY_AGREEMENTKU_KEY_CERT_SIGNKU_CRL_SIGNKU_ENCIPHER_ONLYKU_DECIPHER_ONLY
these correspond to individual key usage bits π« if key usage is absent, UINT32_MAX is returned.
the following aliases for these flags are defined in <openssl/x509.h>:
X509v3_KU_DIGITAL_SIGNATUREX509v3_KU_NON_REPUDIATIONX509v3_KU_KEY_ENCIPHERMENTX509v3_KU_DATA_ENCIPHERMENTX509v3_KU_KEY_AGREEMENTX509v3_KU_KEY_CERT_SIGNX509v3_KU_CRL_SIGNX509v3_KU_ENCIPHER_ONLYX509v3_KU_DECIPHER_ONLY
X509_get_extended_key_usage() returns the value of the extended key usage extension. if extended key usage is present, it returns zero or more of these flags:
XKU_SSL_SERVERXKU_SSL_CLIENTXKU_SMIMEXKU_CODE_SIGNXKU_OCSP_SIGNXKU_TIMESTAMPXKU_DVCSXKU_ANYEKU
these correspond to the OIDs "id-kp-serverAuth", "id-kp-clientAuth", "id-kp-emailProtection", "id-kp-codeSigning", "id-kp-OCSPSigning", "id-kp-timeStamping", "id-kp-dvcs", and "anyExtendedKeyUsage", respectively π
plus, XKU_SGC is set if either Netscape or Microsoft SGC OIDs are present. extra little bonus flag.
the value of the flags correspond to extension values which are cached in the X509 structure. if the flags returned do not provide sufficient information, an application should examine extension values directly, for example using X509_get_ext_d2i(3).
if the key usage or extended key usage extension is absent then typically usage is unrestricted. for this reason X509_get_key_usage() and X509_get_extended_key_usage() return UINT32_MAX when the corresponding extension is absent. applications can additionally check the return value of X509_get_extension_flags() and take appropriate action if an extension is absent.
π«Ά RETURN VALUES π«Ά
X509_get_extension_flags(), X509_get_key_usage() and X509_get_extended_key_usage() return sets of flags corresponding to the certificate extension values. that's the tea β
π¦ SEE ALSO π¦
BASIC_CONSTRAINTS_new(3)EXTENDED_KEY_USAGE_new(3)POLICYINFO_new(3)X509_check_ca(3)X509_check_purpose(3)X509_EXTENSION_new(3)X509_get_ext_d2i(3)X509_get_subject_name(3)X509_get_version(3)X509_new(3)
β HISTORY β
X509_get_extension_flags, X509_get_key_usage, and X509_get_extended_key_usage first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 7.1. glow-up timeline β¨
byeee π this page is from the Debian source/version, dated June 8, 2025, and the manual title is X509_GET_EXTENSION_FLAGS(3) β slay and stay safe π«Ά
π¦ 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) 2015 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