xref: /openssl/doc/man3/SSL_CTX_config.pod (revision 454afd98)
1=pod
2
3=head1 NAME
4
5SSL_CTX_config, SSL_config - configure SSL_CTX or SSL structure
6
7=head1 SYNOPSIS
8
9 #include <openssl/ssl.h>
10
11 int SSL_CTX_config(SSL_CTX *ctx, const char *name);
12 int SSL_config(SSL *s, const char *name);
13
14=head1 DESCRIPTION
15
16The functions SSL_CTX_config() and SSL_config() configure an B<SSL_CTX> or
17B<SSL> structure using the configuration B<name>.
18
19By calling SSL_CTX_config() or SSL_config() an application can perform many
20complex tasks based on the contents of the configuration file: greatly
21simplifying application configuration code. A degree of future proofing
22can also be achieved: an application can support configuration features
23in newer versions of OpenSSL automatically.
24
25A configuration file must have been previously loaded, for example using
26CONF_modules_load_file(). See L<config(5)> for details of the configuration
27file syntax.
28
29=head1 RETURN VALUES
30
31SSL_CTX_config() and SSL_config() return 1 for success or 0 if an error
32occurred.
33
34=head1 EXAMPLES
35
36If the file "config.cnf" contains the following:
37
38 testapp = test_sect
39
40 [test_sect]
41 # list of configuration modules
42
43 ssl_conf = ssl_sect
44
45 [ssl_sect]
46 server = server_section
47
48 [server_section]
49 RSA.Certificate = server-rsa.pem
50 ECDSA.Certificate = server-ecdsa.pem
51 Ciphers = ALL:!RC4
52
53An application could call:
54
55 if (CONF_modules_load_file("config.cnf", "testapp", 0) <= 0) {
56     fprintf(stderr, "Error processing config file\n");
57     goto err;
58 }
59
60 ctx = SSL_CTX_new(TLS_server_method());
61
62 if (SSL_CTX_config(ctx, "server") == 0) {
63     fprintf(stderr, "Error configuring server.\n");
64     goto err;
65 }
66
67In this example two certificates and the cipher list are configured without
68the need for any additional application code.
69
70=head1 SEE ALSO
71
72L<ssl(7)>,
73L<config(5)>,
74L<SSL_CONF_cmd(3)>,
75L<CONF_modules_load_file(3)>
76
77=head1 HISTORY
78
79The SSL_CTX_config() and SSL_config() functions were added in OpenSSL 1.1.0.
80
81=head1 COPYRIGHT
82
83Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
84
85Licensed under the Apache License 2.0 (the "License").  You may not use
86this file except in compliance with the License.  You can obtain a copy
87in the file LICENSE in the source distribution or at
88L<https://www.openssl.org/source/license.html>.
89
90=cut
91