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 ofextoobj. here's the thing: theobjpointer gets duplicated internally, so you should freeobjafter use. it made its own copy, it's not borrowing yours, periodt.X509_EXTENSION_set_critical()β sets the criticality ofextocrit. ifcritis 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 extensionextodata. and yes, thedatapointer 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 typenid, criticalitycrit, using datadata. the created extension gets returned and written to*ex, reusing or allocating a new extension if necessary. so*exshould either beNULLor a validX509_EXTENSIONstructure.
β οΈ 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 toX509_EXTENSION_create_by_NID()except it creates an extension usingobjinstead of a NID. same energy, different identifier π.X509_EXTENSION_get_object()β returns the extension type ofexas anASN1_OBJECTpointer. 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 extensionex. returns1for critical and0for non-critical.X509_EXTENSION_get_data()β returns the data of extensionex. 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()andX509_EXTENSION_set_data()return1for success and0for failure.X509_EXTENSION_create_by_NID()andX509_EXTENSION_create_by_OBJ()return anX509_EXTENSIONpointer, orNULLif an error occurs.X509_EXTENSION_get_object()returns anASN1_OBJECTpointer.X509_EXTENSION_get_critical()returns0for non-critical and1for critical.X509_EXTENSION_get_data()returns anASN1_OCTET_STRINGpointer.
π SEE ALSO π
X509V3_get_d2i(3) β go read that one too, bestie β¨
β COPYRIGHT β
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
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms