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 new CONF object up in heap memory, and assigns it a context libctx that can get used while loading. if the method table meth is NULL, then it just uses the default value from NCONF_default(). easy peasy πŸ“
  • NCONF_new() β€” literally the same vibe as NCONF_new_ex() except it sets the libctx to NULL. that's the whole difference bestie.
  • NCONF_free() β€” frees all the data hanging off of conf, and then frees the conf object itself. and if you pass it NULL? it does nothing. no crash, no drama, just silence πŸ™ˆ

πŸ¦‹ loading stuff

  • NCONF_load() β€” parses the file named filename and adds all the values it finds into conf. and if something goes wrong, file and eline will list the file and the line where the load failed β€” but only if they're not NULL, okay? if you passed NULL you 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 the conf parameter. that's it, that's the function.
  • NCONF_get_section_names() β€” gets the names of the sections associated with conf, as STACK_OF(OPENSSL_CSTRING) strings. ⚠️ heads up: the individual strings are associated with conf and will be invalid after conf is freed β€” so don't be holding onto them, okay? also the returned stack must be freed with sk_OPENSSL_CSTRING_free().
  • NCONF_get_section() β€” gets the config values associated with conf from the config section name, as STACK_OF(CONF_VALUE) structures. ⚠️ and this returned stack is also associated with conf and goes invalid after conf is 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() returns 1 on success or 0 on error. slay or flop, binary queen ✨
  • NCONF_new_ex() and NCONF_new() return a freshly created CONF object, or NULL if an error happens 😭

🌈 SEE ALSO 🌈

CONF_modules_load_file(3)


πŸŽ€ 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 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