1CONFIG(5) OpenSSL CONFIG(5)
2
3
4
6 config - OpenSSL CONF library configuration files
7
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
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 system_default = system_default_sect
261
262 [system_default_sect]
263 MinProtocol = TLSv1.2
264 MinProtocol = DTLSv1.2
265
267 If a configuration file attempts to expand a variable that doesn't
268 exist then an error is flagged and the file will not load. This can
269 happen if an attempt is made to expand an environment variable that
270 doesn't exist. For example in a previous version of OpenSSL the default
271 OpenSSL master configuration file used the value of HOME which may not
272 be defined on non Unix systems and would cause an error.
273
274 This can be worked around by including a default section to provide a
275 default value: then if the environment lookup fails the default value
276 will be used instead. For this to work properly the default value must
277 be defined earlier in the configuration file than the expansion. See
278 the EXAMPLES section for an example of how to do this.
279
280 If the same variable exists in the same section then all but the last
281 value will be silently ignored. In certain circumstances such as with
282 DNs the same field may occur multiple times. This is usually worked
283 around by ignoring any characters before an initial . e.g.
284
285 1.OU="My first OU"
286 2.OU="My Second OU"
287
289 Here is a sample configuration file using some of the features
290 mentioned above.
291
292 # This is the default section.
293
294 HOME=/temp
295 RANDFILE= ${ENV::HOME}/.rnd
296 configdir=$ENV::HOME/config
297
298 [ section_one ]
299
300 # We are now in section one.
301
302 # Quotes permit leading and trailing whitespace
303 any = " any variable name "
304
305 other = A string that can \
306 cover several lines \
307 by including \\ characters
308
309 message = Hello World\n
310
311 [ section_two ]
312
313 greeting = $section_one::message
314
315 This next example shows how to expand environment variables safely.
316
317 Suppose you want a variable called tmpfile to refer to a temporary
318 filename. The directory it is placed in can determined by the TEMP or
319 TMP environment variables but they may not be set to any value at all.
320 If you just include the environment variable names and the variable
321 doesn't exist then this will cause an error when an attempt is made to
322 load the configuration file. By making use of the default section both
323 values can be looked up with TEMP taking priority and /tmp used if
324 neither is defined:
325
326 TMP=/tmp
327 # The above value is used if TMP isn't in the environment
328 TEMP=$ENV::TMP
329 # The above value is used if TEMP isn't in the environment
330 tmpfile=${ENV::TEMP}/tmp.filename
331
332 Simple OpenSSL library configuration example to enter FIPS mode:
333
334 # Default appname: should match "appname" parameter (if any)
335 # supplied to CONF_modules_load_file et al.
336 openssl_conf = openssl_conf_section
337
338 [openssl_conf_section]
339 # Configuration module list
340 alg_section = evp_sect
341
342 [evp_sect]
343 # Set to "yes" to enter FIPS mode if supported
344 fips_mode = yes
345
346 Note: in the above example you will get an error in non FIPS capable
347 versions of OpenSSL.
348
349 Simple OpenSSL library configuration to make TLS 1.2 and DTLS 1.2 the
350 system-default minimum TLS and DTLS versions, respectively:
351
352 # Toplevel section for openssl (including libssl)
353 openssl_conf = default_conf_section
354
355 [default_conf_section]
356 # We only specify configuration for the "ssl module"
357 ssl_conf = ssl_section
358
359 [ssl_section]
360 system_default = system_default_section
361
362 [system_default_section]
363 MinProtocol = TLSv1.2
364 MinProtocol = DTLSv1.2
365
366 The minimum TLS protocol is applied to SSL_CTX objects that are TLS-
367 based, and the minimum DTLS protocol to those are DTLS-based. The same
368 applies also to maximum versions set with MaxProtocol.
369
370 More complex OpenSSL library configuration. Add OID and don't enter
371 FIPS mode:
372
373 # Default appname: should match "appname" parameter (if any)
374 # supplied to CONF_modules_load_file et al.
375 openssl_conf = openssl_conf_section
376
377 [openssl_conf_section]
378 # Configuration module list
379 alg_section = evp_sect
380 oid_section = new_oids
381
382 [evp_sect]
383 # This will have no effect as FIPS mode is off by default.
384 # Set to "yes" to enter FIPS mode, if supported
385 fips_mode = no
386
387 [new_oids]
388 # New OID, just short name
389 newoid1 = 1.2.3.4.1
390 # New OID shortname and long name
391 newoid2 = New OID 2 long name, 1.2.3.4.2
392
393 The above examples can be used with any application supporting library
394 configuration if "openssl_conf" is modified to match the appropriate
395 "appname".
396
397 For example if the second sample file above is saved to "example.cnf"
398 then the command line:
399
400 OPENSSL_CONF=example.cnf openssl asn1parse -genstr OID:1.2.3.4.1
401
402 will output:
403
404 0:d=0 hl=2 l= 4 prim: OBJECT :newoid1
405
406 showing that the OID "newoid1" has been added as "1.2.3.4.1".
407
409 OPENSSL_CONF
410 The path to the config file. Ignored in set-user-ID and set-group-
411 ID programs.
412
413 OPENSSL_ENGINES
414 The path to the engines directory. Ignored in set-user-ID and set-
415 group-ID programs.
416
418 Currently there is no way to include characters using the octal \nnn
419 form. Strings are all null terminated so nulls cannot form part of the
420 value.
421
422 The escaping isn't quite right: if you want to use sequences like \n
423 you can't use any quote escaping on the same line.
424
425 Files are loaded in a single pass. This means that a variable expansion
426 will only work if the variables referenced are defined earlier in the
427 file.
428
430 x509(1), req(1), ca(1)
431
433 Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
434
435 Licensed under the OpenSSL license (the "License"). You may not use
436 this file except in compliance with the License. You can obtain a copy
437 in the file LICENSE in the source distribution or at
438 <https://www.openssl.org/source/license.html>.
439
440
441
4421.1.1k 2021-03-26 CONFIG(5)