---
name: "libressl-CONF_modules_load_file"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-CONF_modules_load_file"
---

# libressl-CONF\_modules\_load\_file(3)

OpenSSL configuration functions

## NAME

**CONF\_modules\_load\_file**, **CONF\_modules\_load**, **X509\_get\_default\_cert\_area** – OpenSSL configuration functions

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/conf.h\>**

*int*\

**CONF\_modules\_load\_file**(*const char \*filename*, *const char \*appname*, *unsigned long flags*);

*int*\

**CONF\_modules\_load**(*const CONF \*cnf*, *const char \*appname*, *unsigned long flags*);

**#include \<openssl/x509.h\>**

*const* *char* *\**\

**X509\_get\_default\_cert\_area**(*void*);

## DESCRIPTION

The function **CONF\_modules\_load\_file**() configures OpenSSL using the file *filename* in [openssl.cnf(5)](/openssl.cnf/5.md) format and the application name *appname*. If *filename* is NULL, the standard OpenSSL configuration file */etc/ssl/openssl.cnf* is used. If *appname* is NULL, the standard OpenSSL application name "openssl\_conf" is used. The behaviour can be customized using *flags*.

See the EXAMPLES section for additional functions that may need to be called. Calling configuration functions in the right order for the intended effect can be tricky because many configuration functions internally call each other.

**CONF\_modules\_load**() is identical to **CONF\_modules\_load\_file**() except it reads configuration information from *cnf*.

The following *flags* are currently recognized:

- CONF\_MFLAGS\_IGNORE\_ERRORS

  Ignore errors returned by individual configuration modules. By default, the first module error is considered fatal and no further modules are loaded.

- CONF\_MFLAGS\_SILENT

  Do not add any error information. By default, all module errors add error information to the error queue.

- CONF\_MFLAGS\_NO\_DSO

  Disable loading of configuration modules from DSOs. This flag is provided for compatibility and has no effect.

- CONF\_MFLAGS\_IGNORE\_MISSING\_FILE

  Let **CONF\_modules\_load\_file**() ignore missing configuration files. By default, a missing configuration file returns an error.

- CONF\_MFLAGS\_DEFAULT\_SECTION

  If *appname* is not NULL but does not exist, fall back to the default section "openssl\_conf".

By using **CONF\_modules\_load\_file**() with appropriate flags, an application can customise application configuration to best suit its needs. In some cases the use of a configuration file is optional and its absence is not an error: in this case CONF\_MFLAGS\_IGNORE\_MISSING\_FILE would be set.

Errors during configuration may also be handled differently by different applications. For example in some cases an error may simply print out a warning message and the application may continue. In other cases an application might consider a configuration file error fatal and exit immediately.

Applications can use the **CONF\_modules\_load**() function if they wish to load a configuration file themselves and have finer control over how errors are treated.

## RETURN VALUES

**CONF\_modules\_load\_file**() and **CONF\_modules\_load**() return 1 for success and zero or a negative value for failure. If module errors are not ignored, the return code will reflect the return value of the failing module (this will always be zero or negative).

**X509\_get\_default\_cert\_area**() returns a pointer to the constant string "/etc/ssl".

## FILES

- */etc/ssl*

  standard configuration directory

- */etc/ssl/openssl.cnf*

  standard configuration file

## EXAMPLES

Load a configuration file and print out any errors and exit (missing file considered fatal):

```
if (CONF_modules_load_file(NULL, NULL, 0) <= 0) {
	fprintf(stderr, "FATAL: error loading configuration file\n");
	ERR_print_errors_fp(stderr);
	exit(1);
}
```

Load default configuration file using the section indicated by "myapp", tolerate missing files, but exit on other errors:

```
if (CONF_modules_load_file(NULL, "myapp",
    CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) {
	fprintf(stderr, "FATAL: error loading configuration file\n");
	ERR_print_errors_fp(stderr);
	exit(1);
}
```

Load custom configuration file and section instead of the standard one, only print warnings on error, missing configuration file ignored:

```
OPENSSL_no_config();
if (CONF_modules_load_file("/something/app.cnf", "myapp",
    CONF_MFLAGS_IGNORE_MISSING_FILE) <= 0) {
	fprintf(stderr, "WARNING: error loading configuration file\n");
	ERR_print_errors_fp(stderr);
}
```

In the previous example, the call to OPENSSL\_no\_config(3) is required first to suppress automatic loading of the standard configuration file.

Load and parse configuration file manually, custom error handling:

```
FILE	*fp;
CONF	*cnf = NULL;
long	 eline;
fp = fopen("/somepath/app.cnf", "r");
if (fp == NULL) {
	fprintf(stderr, "Error opening configuration file\n");
	/* Other missing configuration file behaviour */
} else {
	cnf = NCONF_new(NULL);
	if (NCONF_load_fp(cnf, fp, &eline) == 0) {
		fprintf(stderr, "Error on line %ld of configuration file\n",
		    eline);
		ERR_print_errors_fp(stderr);
		/* Other malformed configuration file behaviour */
	} else if (CONF_modules_load(cnf, "appname", 0) <= 0) {
		fprintf(stderr, "Error configuring application\n");
		ERR_print_errors_fp(stderr);
		/* Other configuration error behaviour */
	}
	fclose(fp);
	NCONF_free(cnf);
}
```

## SEE ALSO

CONF\_modules\_free(3), ERR(3), OPENSSL\_config(3)

## HISTORY

**X509\_get\_default\_cert\_area**() first appeared in SSLeay 0.4.1 and has been available since OpenBSD 2.4.

**CONF\_modules\_load\_file**() and **CONF\_modules\_load**() first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2.
