X509_GET_VERSION(3ossl)
π X509_GET_VERSION(3ossl) β the OpenSSL manual page, bestie edition β¨
Okay so listen, this is the OpenSSL manual for X509_GET_VERSION(3ossl) and we're about to get into certificate version numbers. It's giving "who even uses X.509 versions?" but honestly? Lowkey important. Let's go π«Ά
β¨ NAME β¨
X509_get_version, X509_set_version, X509_REQ_get_version, X509_REQ_set_version, X509_ACERT_get_version, X509_ACERT_set_version, X509_CRL_get_version, X509_CRL_set_version β get or set certificate, certificate request or CRL version. Periodt π
πΈ SYNOPSIS πΈ
#include <openssl/x509.h>
long X509_get_version(const X509 *x);
int X509_set_version(X509 *x, long version);
long X509_REQ_get_version(const X509_REQ *req);
int X509_REQ_set_version(X509_REQ *x, long version);
long X509_CRL_get_version(const X509_CRL *crl);
int X509_CRL_set_version(X509_CRL *x, long version);
#include <openssl/x509_acert.h>
int X509_ACERT_set_version(X509_ACERT *x, long version);
long X509_ACERT_get_version(const X509_ACERT *x);
π DESCRIPTION π
Okay so X509_get_version() returns the numerical value of the version field of certificate x. These correspond to the constants X509_VERSION_1, X509_VERSION_2, and X509_VERSION_3.
Not me about to drop some lore: the values of these constants are defined by standards (X.509 et al) to be one less than the certificate version. So X509_VERSION_3 has value 2 and X509_VERSION_1 has value 0. Like, why? Standards said so. We don't question the standards bestie, we just vibe with them π
X509_set_version() sets the numerical value of the version field of certificate x to version.
Similarly, X509_REQ_get_version(), X509_REQ_set_version(), X509_ACERT_get_version(), X509_ACERT_set_version(), X509_CRL_get_version() and X509_CRL_set_version() get and set the version number of certificate requests and CRLs. They use constants X509_REQ_VERSION_1, X509_ACERT_VERSION_2, X509_CRL_VERSION_1, and X509_CRL_VERSION_2. Slay β¨
π¦ NOTES π¦
The version field of certificates, certificate requests and CRLs has a DEFAULT value of v1(0) β meaning the field should be omitted for version 1. This is handled transparently by these functions. Iconic behavior honestly, they just handle it for you without making it weird π
π₯ RETURN VALUES π₯
X509_get_version(),X509_REQ_get_version()andX509_CRL_get_version()return the numerical value of the version field. Like, the actual number bestie πX509_set_version(),X509_REQ_set_version()andX509_CRL_set_version()return1for success and0for failure. That's it. That's the whole vibe check. 1 = slay, 0 = not slay π
π SEE ALSO π
Honestly just go read these if you're curious, they're all besties:
d2i_X509(3), ERR_get_error(3), X509_CRL_get0_by_serial(3), X509_get0_signature(3), X509_get_ext_d2i(3), X509_get_extension_flags(3), X509_get_pubkey(3), X509_get_subject_name(3), X509_NAME_add_entry_by_txt(3), X509_NAME_ENTRY_get_object(3), X509_NAME_get_index_by_NID(3), X509_NAME_print_ex(3), X509_new(3), X509_sign(3), X509V3_get_d2i(3), X509_verify_cert(3)
π HISTORY π
X509_get_version(), X509_REQ_get_version() and X509_CRL_get_version() are functions in OpenSSL 1.1.0 β in previous versions they were macros. The way they upgraded from macros to actual functions? Main character energy fr fr β¨
X509_ACERT_get_version(), X509_ACERT_set_version() were added in OpenSSL 3.4. Late to the party but we still love them π«Ά
π COPYRIGHT π
Copyright 2015-2024 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>.
No cap: if you're messing with version numbers and you don't read this page, that's on you bestie π
And that's the whole manual! This iconic page is brought to you by OpenSSL 3.5.6, dated 2026-04-07, and it's literally the X509_GET_VERSION(3ossl) manual. Now go forth and version your certificates correctly π
β¨π
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms