1CONFIG(5)                           OpenSSL                          CONFIG(5)
2
3
4

NAME

6       config - OpenSSL CONF library configuration files
7

DESCRIPTION

9       The OpenSSL CONF library can be used to read configuration files.  It
10       is used for the OpenSSL master configuration file openssl.cnf and in a
11       few other places like SPKAC files and certificate extension files for
12       the x509 utility. OpenSSL applications can also use the CONF library
13       for their own purposes.
14
15       A configuration file is divided into a number of sections. Each section
16       starts with a line [ section_name ] and ends when a new section is
17       started or end of file is reached. A section name can consist of
18       alphanumeric characters and underscores.
19
20       The first section of a configuration file is special and is referred to
21       as the default section. This section is usually unnamed and spans from
22       the start of file until the first named section. When a name is being
23       looked up it is first looked up in a named section (if any) and then
24       the default section.
25
26       The environment is mapped onto a section called ENV.
27
28       Comments can be included by preceding them with the # character
29
30       Other files can be included using the .include directive followed by a
31       path. If the path points to a directory all files with names ending
32       with .cnf or .conf are included from the directory.  Recursive
33       inclusion of directories from files in such directory is not supported.
34       That means the files in the included directory can also contain
35       .include directives but only inclusion of regular files is supported
36       there. The inclusion of directories is not supported on systems without
37       POSIX IO support.
38
39       It is strongly recommended to use absolute paths with the .include
40       directive. Relative paths are evaluated based on the application
41       current working directory so unless the configuration file containing
42       the .include directive is application specific the inclusion will not
43       work as expected.
44
45       There can be optional = character and whitespace characters between
46       .include directive and the path which can be useful in cases the
47       configuration file needs to be loaded by old OpenSSL versions which do
48       not support the .include syntax. They would bail out with error if the
49       = character is not present but with it they just ignore the include.
50
51       Each section in a configuration file consists of a number of name and
52       value pairs of the form name=value
53
54       The name string can contain any alphanumeric characters as well as a
55       few punctuation symbols such as . , ; and _.
56
57       The value string consists of the string following the = character until
58       end of line with any leading and trailing white space removed.
59
60       The value string undergoes variable expansion. This can be done by
61       including the form $var or ${var}: this will substitute the value of
62       the named variable in the current section. It is also possible to
63       substitute a value from another section using the syntax $section::name
64       or ${section::name}. By using the form $ENV::name environment variables
65       can be substituted. It is also possible to assign values to environment
66       variables by using the name ENV::name, this will work if the program
67       looks up environment variables using the CONF library instead of
68       calling getenv() directly. The value string must not exceed 64k in
69       length after variable expansion. Otherwise an error will occur.
70
71       It is possible to escape certain characters by using any kind of quote
72       or the \ character. By making the last character of a line a \ a value
73       string can be spread across multiple lines. In addition the sequences
74       \n, \r, \b and \t are recognized.
75
76       All expansion and escape rules as described above that apply to value
77       also apply to the path of the .include directive.
78

OPENSSL LIBRARY CONFIGURATION

80       Applications can automatically configure certain aspects of OpenSSL
81       using the master OpenSSL configuration file, or optionally an
82       alternative configuration file. The openssl utility includes this
83       functionality: any sub command uses the master OpenSSL configuration
84       file unless an option is used in the sub command to use an alternative
85       configuration file.
86
87       To enable library configuration the default section needs to contain an
88       appropriate line which points to the main configuration section. The
89       default name is openssl_conf which is used by the openssl utility.
90       Other applications may use an alternative name such as
91       myapplication_conf.  All library configuration lines appear in the
92       default section at the start of the configuration file.
93
94       The configuration section should consist of a set of name value pairs
95       which contain specific module configuration information. The name
96       represents the name of the configuration module. The meaning of the
97       value is module specific: it may, for example, represent a further
98       configuration section containing configuration module specific
99       information. E.g.:
100
101        # This must be in the default section
102        openssl_conf = openssl_init
103
104        [openssl_init]
105
106        oid_section = new_oids
107        engines = engine_section
108
109        [new_oids]
110
111        ... new oids here ...
112
113        [engine_section]
114
115        ... engine stuff here ...
116
117       The features of each configuration module are described below.
118
119   ASN1 Object Configuration Module
120       This module has the name oid_section. The value of this variable points
121       to a section containing name value pairs of OIDs: the name is the OID
122       short and long name, the value is the numerical form of the OID.
123       Although some of the openssl utility sub commands already have their
124       own ASN1 OBJECT section functionality not all do. By using the ASN1
125       OBJECT configuration module all the openssl utility sub commands can
126       see the new objects as well as any compliant applications. For example:
127
128        [new_oids]
129
130        some_new_oid = 1.2.3.4
131        some_other_oid = 1.2.3.5
132
133       It is also possible to set the value to the long name followed by a
134       comma and the numerical OID form. For example:
135
136        shortName = some object long name, 1.2.3.4
137
138   Engine Configuration Module
139       This ENGINE configuration module has the name engines. The value of
140       this variable points to a section containing further ENGINE
141       configuration information.
142
143       The section pointed to by engines is a table of engine names (though
144       see engine_id below) and further sections containing configuration
145       information specific to each ENGINE.
146
147       Each ENGINE specific section is used to set default algorithms, load
148       dynamic, perform initialization and send ctrls. The actual operation
149       performed depends on the command name which is the name of the name
150       value pair. The currently supported commands are listed below.
151
152       For example:
153
154        [engine_section]
155
156        # Configure ENGINE named "foo"
157        foo = foo_section
158        # Configure ENGINE named "bar"
159        bar = bar_section
160
161        [foo_section]
162        ... foo ENGINE specific commands ...
163
164        [bar_section]
165        ... "bar" ENGINE specific commands ...
166
167       The command engine_id is used to give the ENGINE name. If used this
168       command must be first. For example:
169
170        [engine_section]
171        # This would normally handle an ENGINE named "foo"
172        foo = foo_section
173
174        [foo_section]
175        # Override default name and use "myfoo" instead.
176        engine_id = myfoo
177
178       The command dynamic_path loads and adds an ENGINE from the given path.
179       It is equivalent to sending the ctrls SO_PATH with the path argument
180       followed by LIST_ADD with value 2 and LOAD to the dynamic ENGINE. If
181       this is not the required behaviour then alternative ctrls can be sent
182       directly to the dynamic ENGINE using ctrl commands.
183
184       The command init determines whether to initialize the ENGINE. If the
185       value is 0 the ENGINE will not be initialized, if 1 and attempt it made
186       to initialized the ENGINE immediately. If the init command is not
187       present then an attempt will be made to initialize the ENGINE after all
188       commands in its section have been processed.
189
190       The command default_algorithms sets the default algorithms an ENGINE
191       will supply using the functions ENGINE_set_default_string().
192
193       If the name matches none of the above command names it is assumed to be
194       a ctrl command which is sent to the ENGINE. The value of the command is
195       the argument to the ctrl command. If the value is the string EMPTY then
196       no value is sent to the command.
197
198       For example:
199
200        [engine_section]
201
202        # Configure ENGINE named "foo"
203        foo = foo_section
204
205        [foo_section]
206        # Load engine from DSO
207        dynamic_path = /some/path/fooengine.so
208        # A foo specific ctrl.
209        some_ctrl = some_value
210        # Another ctrl that doesn't take a value.
211        other_ctrl = EMPTY
212        # Supply all default algorithms
213        default_algorithms = ALL
214
215   EVP Configuration Module
216       This modules has the name alg_section which points to a section
217       containing algorithm commands.
218
219       Currently the only algorithm command supported is fips_mode whose value
220       can only be the boolean string off. If fips_mode is set to on, an error
221       occurs as this library version is not FIPS capable.
222
223   SSL Configuration Module
224       This module has the name ssl_conf which points to a section containing
225       SSL configurations.
226
227       Each line in the SSL configuration section contains the name of the
228       configuration and the section containing it.
229
230       Each configuration section consists of command value pairs for
231       SSL_CONF.  Each pair will be passed to a SSL_CTX or SSL structure if it
232       calls SSL_CTX_config() or SSL_config() with the appropriate
233       configuration name.
234
235       Note: any characters before an initial dot in the configuration section
236       are ignored so the same command can be used multiple times.
237
238       For example:
239
240        ssl_conf = ssl_sect
241
242        [ssl_sect]
243
244        server = server_section
245
246        [server_section]
247
248        RSA.Certificate = server-rsa.pem
249        ECDSA.Certificate = server-ecdsa.pem
250        Ciphers = ALL:!RC4
251
252       The system default configuration with name system_default if present
253       will be applied during any creation of the SSL_CTX structure.
254
255       Example of a configuration with the system default:
256
257        ssl_conf = ssl_sect
258
259        [ssl_sect]
260
261        system_default = system_default_sect
262
263        [system_default_sect]
264
265        MinProtocol = TLSv1.2
266

NOTES

268       If a configuration file attempts to expand a variable that doesn't
269       exist then an error is flagged and the file will not load. This can
270       happen if an attempt is made to expand an environment variable that
271       doesn't exist. For example in a previous version of OpenSSL the default
272       OpenSSL master configuration file used the value of HOME which may not
273       be defined on non Unix systems and would cause an error.
274
275       This can be worked around by including a default section to provide a
276       default value: then if the environment lookup fails the default value
277       will be used instead. For this to work properly the default value must
278       be defined earlier in the configuration file than the expansion. See
279       the EXAMPLES section for an example of how to do this.
280
281       If the same variable exists in the same section then all but the last
282       value will be silently ignored. In certain circumstances such as with
283       DNs the same field may occur multiple times. This is usually worked
284       around by ignoring any characters before an initial . e.g.
285
286        1.OU="My first OU"
287        2.OU="My Second OU"
288

EXAMPLES

290       Here is a sample configuration file using some of the features
291       mentioned above.
292
293        # This is the default section.
294
295        HOME=/temp
296        RANDFILE= ${ENV::HOME}/.rnd
297        configdir=$ENV::HOME/config
298
299        [ section_one ]
300
301        # We are now in section one.
302
303        # Quotes permit leading and trailing whitespace
304        any = " any variable name "
305
306        other = A string that can \
307        cover several lines \
308        by including \\ characters
309
310        message = Hello World\n
311
312        [ section_two ]
313
314        greeting = $section_one::message
315
316       This next example shows how to expand environment variables safely.
317
318       Suppose you want a variable called tmpfile to refer to a temporary
319       filename. The directory it is placed in can determined by the TEMP or
320       TMP environment variables but they may not be set to any value at all.
321       If you just include the environment variable names and the variable
322       doesn't exist then this will cause an error when an attempt is made to
323       load the configuration file. By making use of the default section both
324       values can be looked up with TEMP taking priority and /tmp used if
325       neither is defined:
326
327        TMP=/tmp
328        # The above value is used if TMP isn't in the environment
329        TEMP=$ENV::TMP
330        # The above value is used if TEMP isn't in the environment
331        tmpfile=${ENV::TEMP}/tmp.filename
332
333       Simple OpenSSL library configuration example to enter FIPS mode:
334
335        # Default appname: should match "appname" parameter (if any)
336        # supplied to CONF_modules_load_file et al.
337        openssl_conf = openssl_conf_section
338
339        [openssl_conf_section]
340        # Configuration module list
341        alg_section = evp_sect
342
343        [evp_sect]
344        # Set to "yes" to enter FIPS mode if supported
345        fips_mode = yes
346
347       Note: in the above example you will get an error in non FIPS capable
348       versions of OpenSSL.
349
350       Simple OpenSSL library configuration to make TLS 1.3 the system-default
351       minimum TLS version:
352
353        # Toplevel section for openssl (including libssl)
354        openssl_conf = default_conf_section
355
356        [default_conf_section]
357        # We only specify configuration for the "ssl module"
358        ssl_conf = ssl_section
359
360        [ssl_section]
361        system_default = system_default_section
362
363        [system_default_section]
364        MinProtocol = TLSv1.3
365
366       More complex OpenSSL library configuration. Add OID and don't enter
367       FIPS mode:
368
369        # Default appname: should match "appname" parameter (if any)
370        # supplied to CONF_modules_load_file et al.
371        openssl_conf = openssl_conf_section
372
373        [openssl_conf_section]
374        # Configuration module list
375        alg_section = evp_sect
376        oid_section = new_oids
377
378        [evp_sect]
379        # This will have no effect as FIPS mode is off by default.
380        # Set to "yes" to enter FIPS mode, if supported
381        fips_mode = no
382
383        [new_oids]
384        # New OID, just short name
385        newoid1 = 1.2.3.4.1
386        # New OID shortname and long name
387        newoid2 = New OID 2 long name, 1.2.3.4.2
388
389       The above examples can be used with any application supporting library
390       configuration if "openssl_conf" is modified to match the appropriate
391       "appname".
392
393       For example if the second sample file above is saved to "example.cnf"
394       then the command line:
395
396        OPENSSL_CONF=example.cnf openssl asn1parse -genstr OID:1.2.3.4.1
397
398       will output:
399
400           0:d=0  hl=2 l=   4 prim: OBJECT            :newoid1
401
402       showing that the OID "newoid1" has been added as "1.2.3.4.1".
403

ENVIRONMENT

405       OPENSSL_CONF
406           The path to the config file.  Ignored in set-user-ID and set-group-
407           ID programs.
408
409       OPENSSL_ENGINES
410           The path to the engines directory.  Ignored in set-user-ID and set-
411           group-ID programs.
412

BUGS

414       Currently there is no way to include characters using the octal \nnn
415       form. Strings are all null terminated so nulls cannot form part of the
416       value.
417
418       The escaping isn't quite right: if you want to use sequences like \n
419       you can't use any quote escaping on the same line.
420
421       Files are loaded in a single pass. This means that an variable
422       expansion will only work if the variables referenced are defined
423       earlier in the file.
424

SEE ALSO

426       x509(1), req(1), ca(1)
427
429       Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
430
431       Licensed under the OpenSSL license (the "License").  You may not use
432       this file except in compliance with the License.  You can obtain a copy
433       in the file LICENSE in the source distribution or at
434       <https://www.openssl.org/source/license.html>.
435
436
437
4381.1.1g                            2020-04-23                         CONFIG(5)
Impressum