NCONF_NEW_EX(3ossl)
π NCONF_NEW_EX(3ossl) π
okay bestie, listen up β this is the OpenSSL manual page for reading and parsing config files by hand π like, no auto-magic, you're driving stick. it lives in section 3ossl of the OpenSSL docs and it's giving very much "let me handle my own config, thanks". let's get into it π¦
β¨ NAME β¨
NCONF_new_ex, NCONF_new, NCONF_free, NCONF_default, NCONF_load, NCONF_get0_libctx, NCONF_get_section, NCONF_get_section_names β the whole squad whose job is loading and parsing configuration files manually. no cap. you do the parsing, they just hand you the tools π
πΈ SYNOPSIS πΈ
#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);
π DESCRIPTION π
π§ making and destroying the CONF object
NCONF_new_ex()β makes you a brand newCONFobject up in heap memory, and assigns it a contextlibctxthat can get used while loading. if the method tablemethisNULL, then it just uses the default value fromNCONF_default(). easy peasy πNCONF_new()β literally the same vibe asNCONF_new_ex()except it sets thelibctxtoNULL. that's the whole difference bestie.NCONF_free()β frees all the data hanging off ofconf, and then frees theconfobject itself. and if you pass itNULL? it does nothing. no crash, no drama, just silence π
π¦ loading stuff
NCONF_load()β parses the file namedfilenameand adds all the values it finds intoconf. and if something goes wrong,fileandelinewill list the file and the line where the load failed β but only if they're notNULL, okay? if you passedNULLyou get no clues, your fault πNCONF_default()β gets you the default method table for processing a configuration file. it's the standard one, the main character π
π getting info back out
NCONF_get0_libctx()β grabs the library context associated with theconfparameter. that's it, that's the function.NCONF_get_section_names()β gets the names of the sections associated withconf, asSTACK_OF(OPENSSL_CSTRING)strings. β οΈ heads up: the individual strings are associated withconfand will be invalid afterconfis freed β so don't be holding onto them, okay? also the returned stack must be freed withsk_OPENSSL_CSTRING_free().NCONF_get_section()β gets the config values associated withconffrom the config sectionname, asSTACK_OF(CONF_VALUE)structures. β οΈ and this returned stack is also associated withconfand goes invalid afterconfis freed. and β this is the important part β it must not be freed by the caller. do not free it. put the free() down. π ββοΈ
β RETURN VALUES β
NCONF_load()returns1on success or0on error. slay or flop, binary queen β¨NCONF_new_ex()andNCONF_new()return a freshly createdCONFobject, orNULLif an error happens π
π SEE ALSO π
π 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 bestie, hope it served π this was NCONF_NEW_EX(3ossl) from the OpenSSL docs, version 3.5.9, dated 2026-09-29. go forth and parse your configs manually, you absolute legend π«Άβ¨πΈ
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms