X509_EXTENSION_SET_OBJECT(3SSL)

πŸ’… X509_EXTENSION_SET_OBJECT β€” extension utility functions (3SSL, OpenSSL)

okay bestie so this is the X509_EXTENSION_SET_OBJECT(3SSL) page from the OpenSSL manual, and it's literally all about getting stuff in and out of an X509_EXTENSION β€” the little tagged-on blobs that live inside X.509 certs and tell the world extra facts about you. setters, getters, creators, the whole friend group 🫢


✨ NAME ✨

X509_EXTENSION_set_object, X509_EXTENSION_set_critical, X509_EXTENSION_set_data, X509_EXTENSION_create_by_NID, X509_EXTENSION_create_by_OBJ, X509_EXTENSION_get_object, X509_EXTENSION_get_critical, X509_EXTENSION_get_data β€” extension utility functions πŸ’–

🌸 SYNOPSIS 🌸

int X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj);
int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit);
int X509_EXTENSION_set_data(X509_EXTENSION *ex, const ASN1_OCTET_STRING *data);

X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex,
                                             int nid, int crit,
                                             ASN1_OCTET_STRING *data);
X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex,
                                             const ASN1_OBJECT *obj, int crit,
                                             ASN1_OCTET_STRING *data);

const ASN1_OBJECT *X509_EXTENSION_get_object(const X509_EXTENSION *ex);
int X509_EXTENSION_get_critical(const X509_EXTENSION *ex);
const ASN1_OCTET_STRING *X509_EXTENSION_get_data(const X509_EXTENSION *ne);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so, intro time β€” meet the cast πŸ’œ

  • X509_EXTENSION_set_object() β€” sets the extension type of ex to obj. here's the thing: the obj pointer gets duplicated internally, so you should free obj after use. it made its own copy, it's not borrowing yours, periodt.
  • X509_EXTENSION_set_critical() β€” sets the criticality of ex to crit. if crit is zero, the extension is non-critical; otherwise it's critical. that's the whole vibe check: 0 = chill, not-0 = look at me or else.
  • X509_EXTENSION_set_data() β€” sets the data in extension ex to data. and yes, the data pointer is duplicated internally too. it's giving "I made a copy, don't worry about it".
  • X509_EXTENSION_create_by_NID() β€” creates an extension of type nid, criticality crit, using data data. the created extension gets returned and written to *ex, reusing or allocating a new extension if necessary. so *ex should either be NULL or a valid X509_EXTENSION structure.
⚠️ bestie listen β€” it must not be an uninitialised pointer. that's the one thing you cannot do here, no cap. uninitialised pointer = chaos.
  • X509_EXTENSION_create_by_OBJ() β€” identical to X509_EXTENSION_create_by_NID() except it creates an extension using obj instead of a NID. same energy, different identifier 🌈.
  • X509_EXTENSION_get_object() β€” returns the extension type of ex as an ASN1_OBJECT pointer. the returned pointer is an internal value which must not be freed up. don't touch it, don't free it, just look respectfully πŸ™ˆ.
  • X509_EXTENSION_get_critical() β€” returns the criticality of extension ex. returns 1 for critical and 0 for non-critical.
  • X509_EXTENSION_get_data() β€” returns the data of extension ex. the returned pointer is an internal value which must not be freed up. again: look, don't free πŸ’….

πŸ“ NOTES πŸ“

these functions manipulate the contents of an extension directly. and like… most applications do NOT want that. they'll want to parse or encode and add an extension instead β€” in which case they should use the extension encode and decode functions, such as X509_add1_ext_i2d() and X509_get_ext_d2i(). those are your besties here, fr fr.

the data associated with an extension is the extension encoding in an ASN1_OCTET_STRING structure. that's it, that's the deal πŸ“.

πŸ‘‘ RETURN VALUES πŸ‘‘

  • X509_EXTENSION_set_object(), X509_EXTENSION_set_critical() and X509_EXTENSION_set_data() return 1 for success and 0 for failure.
  • X509_EXTENSION_create_by_NID() and X509_EXTENSION_create_by_OBJ() return an X509_EXTENSION pointer, or NULL if an error occurs.
  • X509_EXTENSION_get_object() returns an ASN1_OBJECT pointer.
  • X509_EXTENSION_get_critical() returns 0 for non-critical and 1 for critical.
  • X509_EXTENSION_get_data() returns an ASN1_OCTET_STRING pointer.

πŸ” SEE ALSO πŸ”

X509V3_get_d2i(3) β€” go read that one too, bestie ✨

Copyright 2015-2026 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 4.0.3, dated 2026-09-29, page X509_EXTENSION_SET_OBJECT(3SSL) β€” go forth and set those extensions, you absolute icon πŸ‘‘πŸ’–

πŸ“¦ where this page comes from