I2D_RE_X509_TBS(3ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… i2d_re_X509_tbs β€” X509 encode & decode, bestie edition ✨

Okay so this is the OpenSSL manual page for I2D_RE_X509_TBS(3ossl), and honestly? It's giving "niche but iconic" πŸŽ€ because these functions are the ones that handle X509 certificates β€” encode them, decode them, re-encode their little TBS bits. Buckle up, we're going in πŸ¦‹


✨ NAME ✨

d2i_X509_AUX, i2d_X509_AUX, i2d_re_X509_tbs, i2d_re_X509_CRL_tbs, i2d_re_X509_REQ_tbs β€” the X509 encode and decode functions, aka the glow-up squad for certificates πŸ’…


🌸 SYNOPSIS 🌸

#include <openssl/x509.h>

X509 *d2i_X509_AUX(X509 **px, const unsigned char **in, long len);
int i2d_X509_AUX(const X509 *x, unsigned char **out);
int i2d_re_X509_tbs(X509 *x, unsigned char **out);
int i2d_re_X509_CRL_tbs(X509_CRL *crl, unsigned char **pp);
int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp);

Literally copy-paste energy, no cap 🫢


πŸ’œ DESCRIPTION πŸ’œ

So the X509 encode and decode routines do exactly what they say on the tin: they encode and parse an X509 structure, which represents an X509 certificate. Main character behavior, honestly πŸ‘‘

πŸŽ€ The AUX girlies πŸŽ€

d2i_X509_AUX() is similar to d2i_X509(3) but the input is expected to consist of an X509 certificate followed by auxiliary trust information. This is used by the PEM routines to read "TRUSTED CERTIFICATE" objects. And bestie, listen β€” this function should not be called on untrusted input. That's not a vibe, that's a warning ⚠️

i2d_X509_AUX() is similar to i2d_X509(3), but the encoded output contains both the certificate and any auxiliary trust information. This is used by the PEM routines to write "TRUSTED CERTIFICATE" objects. Note that this is a non-standard OpenSSL-specific data format β€” it's giving "we made this ourselves, and we ate" πŸ’…

πŸ¦‹ The "re" girlies (re-encode, not "regret") πŸ¦‹

i2d_re_X509_tbs() is similar to i2d_X509(3) except it encodes only the TBSCertificate portion of the certificate. i2d_re_X509_CRL_tbs() and i2d_re_X509_REQ_tbs() are analogous for CRL and certificate request, respectively.

The "re" in i2d_re_X509_tbs stands for "re-encode", and it ensures that a fresh encoding is generated in case the object has been modified after creation (see the BUGS section, yes we're looking at you πŸ‘€).

🌈 The caching lore 🌈

The encoding of the TBSCertificate portion of a certificate is cached in the X509 structure internally to improve encoding performance and to ensure certificate signatures are verified correctly in some certificates with broken (non-DER) encodings. Like, it's stored in the group chat for later, iykyk 😭

If, after modification, the X509 object is re-signed with X509_sign(), the encoding is automatically renewed. Otherwise, the encoding of the TBSCertificate portion of the X509 can be manually renewed by calling i2d_re_X509_tbs(). You have options, bestie ✨


πŸ“ RETURN VALUES πŸ“

  • d2i_X509_AUX() returns a valid X509 structure or NULL if an error occurred. If you see NULL, that's not a slay, that's a cry 😭
  • i2d_X509_AUX() returns the length of encoded data or -1 on error.
  • i2d_re_X509_tbs(), i2d_re_X509_CRL_tbs() and i2d_re_X509_REQ_tbs() return the length of encoded data or <=0 on error. Watch that <=, it's not just <, she's special πŸ’€

🧚 SEE ALSO 🧚

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_get_version(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)

Yes, that's a whole friend group. Go say hi 🫢


Copyright 2002-2018 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>.


πŸŽ€ ngl, the license is not the fun part, but it is the part that keeps you out of trouble. Read it, bestie. Or at least keep the file around πŸ’–

And that's the whole page, periodt πŸ’… This was the OpenSSL 3.5.6 manual page, dated 2026-04-07, filed under I2D_RE_X509_TBS(3ossl). Go forth and encode responsibly πŸŒΈπŸ¦‹βœ¨

πŸ“¦ where this page comes from