SSL\_CTX\_CONFIG(3ossl) OpenSSL SSL\_CTX\_CONFIG(3ossl)

# [NAME](#NAME)

SSL\_CTX\_config, SSL\_config - configure SSL\_CTX or SSL structure

# [SYNOPSIS](#SYNOPSIS)

```
 #include <openssl/ssl.h>
 int SSL_CTX_config(SSL_CTX *ctx, const char *name);
 int SSL_config(SSL *s, const char *name);
```

# [DESCRIPTION](#DESCRIPTION)

The functions **SSL\_CTX\_config()** and **SSL\_config()** apply additional configuration settings to an **SSL\_CTX** or **SSL** structure using the configuration **name**. The **name** must match a parameter in the configuration file's **ssl** module section, whose value is the name of another section with SSL configuration commands. See [**SSL\_CONF\_cmd**(3)](/man/os/openssl-4.0/SSL_CONF_cmd.3) for a description of the available commands.

By calling **SSL\_CTX\_config()** or **SSL\_config()** an application can perform many complex tasks based on the contents of the configuration file: greatly simplifying application configuration code. Some future-proofing can be attained this way: the specified configuration section can specify settings supported by the run-time version of OpenSSL that were not known at the time the application code was written.

A configuration file must have been previously loaded, for example using [**CONF\_modules\_load\_file**(3)](/man/os/openssl-4.0/CONF_modules_load_file.3). See [**config**(5)](/man/os/openssl-4.0/config.5) for details of the configuration file syntax. In most applications the default **openssl.cnf** file is loaded automatically as part of library initialisation.

# [RETURN VALUES](#RETURN_VALUES)

**SSL\_CTX\_config()** and **SSL\_config()** return 1 for success or 0 if an error occurred.

# [EXAMPLES](#EXAMPLES)

If, for example, the loaded configuration file contains the following:

```
 # Top level "default" section, if no application name was specified as part
 # initialisation, it defaults to "openssl_conf".
 openssl_conf = openssl_init
 [openssl_init]
 # SSL module initialisation
 ssl_conf = ssl_init
 [ssl_init]
 system_default = default_ssl_settings
 tweaks_for_tls12 = tls12_custom_settings
 tweaks_for_tls13 = tls13_custom_settings
 [default_ssl_settings]
 MinProtocol = TLSv1.2
 # Defaults are typically the wisest choice, override only with good cause.
 MinProtocol = ...
 Ciphers = ...
 Groups = ...
 SignatureAlgorithms = ...
 [tls12_custom_settings]
 # Defaults are typically the wisest choice, override only with good cause.
 MaxProtocol = TLSv1.2
 ...
 [tls13_custom_settings]
 # Defaults are typically the wisest choice, override only with good cause.
 MinProtocol = TLSv1.3
 ...
```

An application that wants to only use "TLS 1.2" might call:

```
 /* Initialised per "system_default" settings */
 if ((ctx = SSL_CTX_new(TLS_server_method())) == NULL) {
     fprintf(stderr, "Error creating the SSL context.\n");
     goto err;
 }
 /*
  * Further tweaks per the "ssl" module "tweaks_for_tls12" setting, i.e. the
  * configuration file's "tls12_custom_settings" section.
  */
 if (SSL_CTX_config(ctx, "tweaks_for_tls12") == 0) {
     fprintf(stderr, "Error applying 'tweaks_for_tls12' context configuration.\n");
     goto err;
 }
```

The setting of the protocol version ceiling and any other settings relevant to TLS 1.2 are in the configuration file, and don't need to be hard-coded in the application. Similarly, using "tweaks\_for\_tls13" as the configuration **name** applies the corresponding settings from the "tls13\_custom\_settings" section (per the SSL module "tweaks\_for\_tls13" parameter).

# [SEE ALSO](#SEE_ALSO)

[**ssl**(7)](/man/os/openssl-4.0/ssl.7), [**config**(5)](/man/os/openssl-4.0/config.5), [**SSL\_CONF\_cmd**(3)](/man/os/openssl-4.0/SSL_CONF_cmd.3), [**SSL\_CTX\_new**(3)](/man/os/openssl-4.0/SSL_CTX_new.3), [**CONF\_modules\_load\_file**(3)](/man/os/openssl-4.0/CONF_modules_load_file.3), [**OPENSSL\_init\_ssl**(3)](/man/os/openssl-4.0/OPENSSL_init_ssl.3)

# [HISTORY](#HISTORY)

The **SSL\_CTX\_config()** and **SSL\_config()** functions were added in OpenSSL 1.1.0.

# [COPYRIGHT](#COPYRIGHT)

Copyright 2015-2020 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 &lt;https://www.openssl.org/source/license.html&gt;.

2026-09-29 4.0.3

---

Document: SSL_config(3ossl) from openssl-4.0 4.0.3-r0 (Chainguard OS)
