1 .\" $OpenBSD: openssl.cnf.5,v 1.3 2017/07/06 15:42:04 schwarze Exp $
2 .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
4 .\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5 .\" Copyright (c) 1999, 2000, 2004, 2013, 2015, 2016 The OpenSSL Project.
6 .\" All rights reserved.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in
17 .\" the documentation and/or other materials provided with the
20 .\" 3. All advertising materials mentioning features or use of this
21 .\" software must display the following acknowledgment:
22 .\" "This product includes software developed by the OpenSSL Project
23 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 .\" endorse or promote products derived from this software without
27 .\" prior written permission. For written permission, please contact
28 .\" openssl-core@openssl.org.
30 .\" 5. Products derived from this software may not be called "OpenSSL"
31 .\" nor may "OpenSSL" appear in their names without prior written
32 .\" permission of the OpenSSL Project.
34 .\" 6. Redistributions of any form whatsoever must retain the following
36 .\" "This product includes software developed by the OpenSSL Project
37 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
52 .Dd $Mdocdate: July 6 2017 $
57 .Nd OpenSSL configuration files
59 The OpenSSL CONF library can be used to read configuration files; see
60 .Xr CONF_modules_load_file 3 .
61 It is used for the OpenSSL master configuration file
62 .Pa /etc/ssl/openssl.cnf
63 and in a few other places like
65 files and certificate extension files for the
69 OpenSSL applications can also use the CONF library for their own
72 A configuration file is divided into a number of sections.
73 Each section starts with a line
75 and ends when a new section is started or the end of the file is reached.
76 A section name can consist of alphanumeric characters and underscores.
78 The first section of a configuration file is special and is referred to
81 It is usually unnamed and extends from the start of file to the
83 When a name is being looked up, it is first looked up in a named
84 section (if any) and then in the default section.
86 The environment is mapped onto a section called
89 Comments can be included by preceding them with the
93 Each section in a configuration file consists of a number of name and
94 value pairs of the form
95 .Ar name Ns = Ns Ar value .
99 string can contain any alphanumeric characters as well as a few
100 punctuation symbols such as
109 string consists of the string following the
111 character until the end of the line with any leading and trailing
114 The value string undergoes variable expansion.
115 This can be done by including substrings of the form
119 this will substitute the value of the named variable in the current
121 It is also possible to substitute a value from another section using the
123 .Pf $ Ar section Ns :: Ns Ar name
125 .Pf $ Brq Ar section Ns :: Ns Ar name .
127 .Pf $ Ic ENV Ns :: Ns Ar name ,
128 environment variables can be substituted.
129 It is also possible to assign values to environment variables by using
131 .Ic ENV Ns :: Ns Ar name .
132 This will work if the program looks up environment variables using
133 the CONF library instead of calling
137 It is possible to escape certain characters by using any kind of quote
141 By making the last character of a line a
145 string can be spread across multiple lines.
146 In addition the sequences
153 .Sh OPENSSL LIBRARY CONFIGURATION
154 Applications can automatically configure certain aspects of OpenSSL
155 using the master OpenSSL configuration file, or optionally an
156 alternative configuration file.
159 utility includes this functionality: any sub command uses the master
160 OpenSSL configuration file unless an option is used in the sub command
161 to use an alternative configuration file.
163 To enable library configuration, the default section needs to contain
164 an appropriate line which points to the main configuration section.
170 Other applications may use an alternative name such as
171 .Sy myapplication_conf .
173 The configuration section should consist of a set of name value pairs
174 which contain specific module configuration information.
177 represents the name of the configuration module.
180 is module specific: it may, for example, represent a further
181 configuration section containing configuration module specific
184 .Bd -literal -offset indent
185 openssl_conf = openssl_init
188 oid_section = new_oids
189 engines = engine_section
192 \&... new oids here ...
195 \&... engine stuff here ...
198 The features of each configuration module are described below.
199 .Ss ASN1 Object Configuration Module
200 This module has the name
202 The value of this variable points to a section containing name value
203 pairs of OIDs: the name is the OID short and long name, and the value is the
204 numerical form of the OID.
207 utility subcommands already have their own ASN1 OBJECT section
208 functionality, not all do.
209 By using the ASN1 OBJECT configuration module, all the
211 utility subcommands can see the new objects as well as any compliant
214 .Bd -literal -offset indent
216 some_new_oid = 1.2.3.4
217 some_other_oid = 1.2.3.5
220 It is also possible to set the value to the long name followed by a
221 comma and the numerical OID form.
224 .Dl shortName = some object long name, 1.2.3.4
225 .Ss Engine Configuration Module
226 This ENGINE configuration module has the name
228 The value of this variable points to a section containing further ENGINE
229 configuration information.
231 The section pointed to by
233 is a table of engine names (though see
235 below) and further sections containing configuration information
236 specific to each ENGINE.
238 Each ENGINE specific section is used to set default algorithms, load
239 dynamic ENGINEs, perform initialization and send ctrls.
240 The actual operation performed depends on the command
241 name which is the name of the name value pair.
242 The currently supported commands are listed below.
245 .Bd -literal -offset indent
247 # Configure ENGINE named "foo"
249 # Configure ENGINE named "bar"
253 \&... foo ENGINE specific commands ...
256 \&... "bar" ENGINE specific commands ...
261 is used to give the ENGINE name.
262 If used this command must be first.
264 .Bd -literal -offset indent
266 # This would normally handle an ENGINE named "foo"
270 # Override default name and use "myfoo" instead.
276 loads and adds an ENGINE from the given path.
277 It is equivalent to sending the ctrls
279 with the path argument followed by
283 to the dynamic ENGINE.
284 If this is not the required behaviour then alternative ctrls can be sent
285 directly to the dynamic ENGINE using ctrl commands.
289 determines whether to initialize the ENGINE.
290 If the value is 0, the ENGINE will not be initialized.
291 If it is 1, an attempt is made to initialized the ENGINE immediately.
294 command is not present, then an attempt will be made to initialize
295 the ENGINE after all commands in its section have been processed.
298 .Ic default_algorithms
299 sets the default algorithms an ENGINE will supply using the functions
300 .Xr ENGINE_set_default_string 3 .
302 If the name matches none of the above command names it is assumed
303 to be a ctrl command which is sent to the ENGINE.
304 The value of the command is the argument to the ctrl command.
305 If the value is the string
307 then no value is sent to the command.
310 .Bd -literal -offset indent
312 # Configure ENGINE named "foo"
316 # Load engine from DSO
317 dynamic_path = /some/path/fooengine.so
318 # A foo specific ctrl.
319 some_ctrl = some_value
320 # Another ctrl that doesn't take a value.
322 # Supply all default algorithms
323 default_algorithms = ALL
326 .Bl -tag -width /etc/ssl/openssl.cnf -compact
327 .It Pa /etc/ssl/openssl.cnf
328 standard configuration file
331 Here is a sample configuration file using some of the features
333 .Bd -literal -offset indent
334 # This is the default section.
336 RANDFILE= ${ENV::HOME}/.rnd
337 configdir=$ENV::HOME/config
340 # We are now in section one.
342 # Quotes permit leading and trailing whitespace
343 any = " any variable name "
345 other = A string that can \e
346 cover several lines \e
347 by including \e\e characters
349 message = Hello World\en
352 greeting = $section_one::message
355 This next example shows how to expand environment variables safely.
357 Suppose you want a variable called
359 to refer to a temporary filename.
360 The directory it is placed in can determined by the
364 environment variables but they may not be set to any value at all.
365 If you just include the environment variable names and the variable
366 doesn't exist then this will cause an error when an attempt is made to
367 load the configuration file.
368 By making use of the default section both values can be looked up with
372 used if neither is defined:
373 .Bd -literal -offset indent
375 # The above value is used if TMP isn't in the environment
377 # The above value is used if TEMP isn't in the environment
378 tmpfile=${ENV::TEMP}/tmp.filename
381 More complex OpenSSL library configuration.
383 .Bd -literal -offset indent
384 # Default appname: should match "appname" parameter (if any)
385 # supplied to CONF_modules_load_file et al.
386 openssl_conf = openssl_conf_section
388 [openssl_conf_section]
389 # Configuration module list
390 alg_section = evp_sect
391 oid_section = new_oids
394 # New OID, just short name
396 # New OID shortname and long name
397 newoid2 = New OID 2 long name, 1.2.3.4.2
400 The above examples can be used with any application supporting library
401 configuration if "openssl_conf" is modified to match the appropriate
404 For example if the second sample file above is saved to "example.cnf"
405 then the command line:
407 .Dl OPENSSL_CONF=example.cnf openssl asn1parse -genstr OID:1.2.3.4.1
410 .Dl 0:d=0 hl=2 l= 4 prim: OBJECT :newoid1
412 showing that the OID "newoid1" has been added as "1.2.3.4.1".
415 .Xr CONF_modules_load_file 3 ,
418 If a configuration file attempts to expand a variable that doesn't
419 exist, then an error is flagged and the file will not load.
420 This can also happen if an attempt is made to expand an environment
421 variable that doesn't exist.
422 For example, in a previous version of OpenSSL the default OpenSSL
423 master configuration file used the value of
425 which may not be defined on non Unix systems and would cause an error.
427 This can be worked around by including a default section to provide
428 a default value: then if the environment lookup fails, the default
429 value will be used instead.
430 For this to work properly, the default value must be defined earlier
431 in the configuration file than the expansion.
434 section for an example of how to do this.
436 If the same variable is defined more than once in the same section,
437 then all but the last value will be silently ignored.
438 In certain circumstances such as with DNs, the same field may occur
440 This is usually worked around by ignoring any characters before an
444 .Bd -literal -offset indent
449 Currently there is no way to include characters using the octal
452 Strings are all NUL terminated, so NUL bytes cannot form part of
455 The escaping isn't quite right: if you want to use sequences like
457 you can't use any quote escaping on the same line.
459 Files are loaded in a single pass.
460 This means that an variable expansion will only work if the variables
461 referenced are defined earlier in the file.