NCONF_NEW_EX(3ossl)
π NCONF_NEW_EX(3ossl) β like, the whole config-file situation, explained
Okay bestie, so this is an OpenSSL page (3ossl, the SSL crew, you know the vibe) and it's literally all about loading and parsing configuration files manually. No cap. The little cast of characters is NCONF_new_ex, NCONF_new, NCONF_free, NCONF_default, NCONF_load, NCONF_get0_libctx, NCONF_get_section, and NCONF_get_section_names β the whole friend group. π«Ά
β¨ SYNOPSIS β¨
Like, here's the incantation, copy it exactly or it won't slay:
#include <openssl/conf.h>
typedef struct {
char *section;
char *name;
char *value;
} CONF_VALUE;
CONF *NCONF_new_ex(OSSL_LIB_CTX *libctx, CONF_METHOD *meth);
CONF *NCONF_new(CONF_METHOD *meth);
void NCONF_free(CONF *conf);
CONF_METHOD *NCONF_default(void);
int NCONF_load(CONF *conf, const char *file, long *eline);
OSSL_LIB_CTX *NCONF_get0_libctx(const CONF *conf);
STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, const char *name);
STACK_OF(OPENSSL_CSTRING) *NCONF_get_section_names(const CONF *conf);
That CONF_VALUE struct? Iconic. Three little char * fields β section, name, value β and that's the whole personality. π
πΈ DESCRIPTION πΈ
Let's go function by function, mwah:
NCONF_new_ex()β creates a brand-newCONFobject in heap memory (yes, heap, she lives on the heap now π§) and assigns to it a contextlibctxthat can be used during loading. And if the method tablemethis set toNULL? Then the default value ofNCONF_default()gets used. Easy.NCONF_new()β basicallyNCONF_new_ex()'s sibling, same energy, except it sets thelibctxtoNULL. That's the whole difference, periodt.NCONF_free()β frees the data associated withconfand then frees theconfobject itself. Cleanup queen. And if the argument isNULL, nothing is done β she simply does not engage. πNCONF_load()β parses the file namedfilenameand adds the values found toconf. And if an error occurs,fileandelinelist the file and line that the load failed on β but only if they're notNULL. So pass them or don't, your call.NCONF_default()β gets the default method table for processing a configuration file. The blueprint, the template, the moment.NCONF_get0_libctx()β gets the library context associated with theconfparameter. Just hands it right back to you.NCONF_get_section_names()β gets the names of the sections associated with theconfasSTACK_OF(OPENSSL_CSTRING)strings. Lowkey important caveat: the individual strings are associated with theconfand will be invalid afterconfis freed. π And the returned stack must be freed withsk_OPENSSL_CSTRING_free(). Don't forget, bestie, that's your job, not hers.NCONF_get_section()β gets the config values associated with theconffrom the config sectionnameasSTACK_OF(CONF_VALUE)structures. Same warning energy: the returned stack is associated with theconfand will be invalid afterconfis freed. And this one must not be freed by the caller β nope, not yours to free, hands off. π
Heads up: those twogetfunctions hand you borrowed pointers. They are not gifts. They evaporate the secondconfgets freed. π¦
β RETURN VALUES β
NCONF_load()β returns1on success or0on error. Binary queen, no in-between.NCONF_new_ex()andNCONF_new()β return a newly createdCONFobject, orNULLif an error occurs. So like, always vibe check that return value. π
π SEE ALSO π
(Yes, it ends with a comma in the original and I'm keeping it, character for character, don't @ me.)
π₯ HISTORY π₯
NCONF_new_ex(), NCONF_get0_libctx(), and NCONF_get_section_names() were added in OpenSSL 3.0. The new girls on the block, and they ate. β¨
π COPYRIGHT π
Copyright 2020-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>. π
Okay that's the whole page, go forth and parse your configs manually like the main character you are. π«Ά
Big kiss, this was OpenSSL 3.5.6, dated 2026-04-07, and the page is NCONF_NEW_EX(3ossl) β slay, bye! π
π¦ 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