xref: /dragonfly/crypto/libressl/man/openssl.cnf.5 (revision 7a047041)
1.\" $OpenBSD: openssl.cnf.5,v 1.5 2019/01/02 07:42:21 jmc Exp $
2.\" full merge up to: OpenSSL man5/config b53338cb Feb 28 12:30:28 2017 +0100
3.\" selective merge up to: OpenSSL a8c5ed81 Jul 18 13:57:25 2017 -0400
4.\"
5.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
6.\" Copyright (c) 1999, 2000, 2004, 2013, 2015, 2016, 2017 The OpenSSL Project.
7.\" All rights reserved.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\"
13.\" 1. Redistributions of source code must retain the above copyright
14.\"    notice, this list of conditions and the following disclaimer.
15.\"
16.\" 2. Redistributions in binary form must reproduce the above copyright
17.\"    notice, this list of conditions and the following disclaimer in
18.\"    the documentation and/or other materials provided with the
19.\"    distribution.
20.\"
21.\" 3. All advertising materials mentioning features or use of this
22.\"    software must display the following acknowledgment:
23.\"    "This product includes software developed by the OpenSSL Project
24.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
25.\"
26.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27.\"    endorse or promote products derived from this software without
28.\"    prior written permission. For written permission, please contact
29.\"    openssl-core@openssl.org.
30.\"
31.\" 5. Products derived from this software may not be called "OpenSSL"
32.\"    nor may "OpenSSL" appear in their names without prior written
33.\"    permission of the OpenSSL Project.
34.\"
35.\" 6. Redistributions of any form whatsoever must retain the following
36.\"    acknowledgment:
37.\"    "This product includes software developed by the OpenSSL Project
38.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
39.\"
40.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
44.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51.\" OF THE POSSIBILITY OF SUCH DAMAGE.
52.\"
53.Dd $Mdocdate: January 2 2019 $
54.Dt OPENSSL.CNF 5
55.Os
56.Sh NAME
57.Nm openssl.cnf
58.Nd OpenSSL configuration files
59.Sh DESCRIPTION
60The OpenSSL CONF library can be used to read configuration files; see
61.Xr CONF_modules_load_file 3 .
62It is used for the OpenSSL master configuration file
63.Pa /etc/ssl/openssl.cnf
64and in a few other places like
65.Sy SPKAC
66files and certificate extension files for the
67.Xr openssl 1
68.Cm x509
69utility.
70OpenSSL applications can also use the CONF library for their own
71purposes.
72.Pp
73A configuration file is divided into a number of sections.
74Each section starts with a line
75.Bq Ar section_name
76and ends when a new section is started or the end of the file is reached.
77A section name can consist of alphanumeric characters and underscores.
78.Pp
79The first section of a configuration file is special and is referred to
80as the
81.Dq default section .
82It is usually unnamed and extends from the start of file to the
83first named section.
84When a name is being looked up, it is first looked up in a named
85section (if any) and then in the default section.
86.Pp
87The environment is mapped onto a section called
88.Ic ENV .
89.Pp
90Comments can be included by preceding them with the
91.Ql #
92character.
93.Pp
94Each section in a configuration file consists of a number of name and
95value pairs of the form
96.Ar name Ns = Ns Ar value .
97.Pp
98The
99.Ar name
100string can contain any alphanumeric characters as well as a few
101punctuation symbols such as
102.Ql \&.
103.Ql \&,
104.Ql \&;
105and
106.Ql _ .
107.Pp
108The
109.Ar value
110string consists of the string following the
111.Ql =
112character until the end of the line with any leading and trailing
113whitespace removed.
114.Pp
115The value string undergoes variable expansion.
116This can be done by including substrings of the form
117.Pf $ Ar name
118or
119.Pf $ Brq Ar name :
120this will substitute the value of the named variable in the current
121section.
122It is also possible to substitute a value from another section using the
123syntax
124.Pf $ Ar section Ns :: Ns Ar name
125or
126.Pf $ Brq Ar section Ns :: Ns Ar name .
127By using the form
128.Pf $ Ic ENV Ns :: Ns Ar name ,
129environment variables can be substituted.
130It is also possible to assign values to environment variables by using
131the name
132.Ic ENV Ns :: Ns Ar name .
133This will work if the program looks up environment variables using
134the CONF library instead of calling
135.Xr getenv 3
136directly.
137.Pp
138It is possible to escape certain characters by using any kind of quote
139or the
140.Ql \e
141character.
142By making the last character of a line a
143.Ql \e ,
144a
145.Ar value
146string can be spread across multiple lines.
147In addition the sequences
148.Ql \en ,
149.Ql \er ,
150.Ql \eb ,
151and
152.Ql \et
153are recognized.
154.Sh OPENSSL LIBRARY CONFIGURATION
155Applications can automatically configure certain aspects of OpenSSL
156using the master OpenSSL configuration file, or optionally an
157alternative configuration file.
158The
159.Xr openssl 1
160utility includes this functionality: any sub command uses the master
161OpenSSL configuration file unless an option is used in the sub command
162to use an alternative configuration file.
163.Pp
164To enable library configuration, the default section needs to contain
165an appropriate line which points to the main configuration section.
166The default name is
167.Ic openssl_conf ,
168which is used by the
169.Xr openssl 1
170utility.
171Other applications may use an alternative name such as
172.Sy myapplication_conf .
173All library configuration lines appear in the default section
174at the start of the configuration file.
175.Pp
176The configuration section should consist of a set of name value pairs
177which contain specific module configuration information.
178The
179.Ar name
180represents the name of the configuration module.
181The meaning of the
182.Ar value
183is module specific: it may, for example, represent a further
184configuration section containing configuration module specific
185information.
186For example:
187.Bd -literal -offset indent
188# The following line must be in the default section.
189openssl_conf = openssl_init
190
191[openssl_init]
192oid_section = new_oids
193engines = engine_section
194
195[new_oids]
196\&... new oids here ...
197
198[engine_section]
199\&... engine stuff here ...
200.Ed
201.Pp
202The features of each configuration module are described below.
203.Ss ASN1 Object Configuration Module
204This module has the name
205.Ic oid_section .
206The value of this variable points to a section containing name value
207pairs of OIDs: the name is the OID short and long name, and the value is the
208numerical form of the OID.
209Although some of the
210.Xr openssl 1
211utility subcommands already have their own ASN1 OBJECT section
212functionality, not all do.
213By using the ASN1 OBJECT configuration module, all the
214.Xr openssl 1
215utility subcommands can see the new objects as well as any compliant
216applications.
217For example:
218.Bd -literal -offset indent
219[new_oids]
220some_new_oid = 1.2.3.4
221some_other_oid = 1.2.3.5
222.Ed
223.Pp
224It is also possible to set the value to the long name followed by a
225comma and the numerical OID form.
226For example:
227.Pp
228.Dl shortName = some object long name, 1.2.3.4
229.Ss Engine Configuration Module
230This ENGINE configuration module has the name
231.Ic engines .
232The value of this variable points to a section containing further ENGINE
233configuration information.
234.Pp
235The section pointed to by
236.Ic engines
237is a table of engine names (though see
238.Ic engine_id
239below) and further sections containing configuration information
240specific to each ENGINE.
241.Pp
242Each ENGINE specific section is used to set default algorithms, load
243dynamic ENGINEs, perform initialization and send ctrls.
244The actual operation performed depends on the command
245name which is the name of the name value pair.
246The currently supported commands are listed below.
247.Pp
248For example:
249.Bd -literal -offset indent
250[engine_section]
251# Configure ENGINE named "foo"
252foo = foo_section
253# Configure ENGINE named "bar"
254bar = bar_section
255
256[foo_section]
257\&... foo ENGINE specific commands ...
258
259[bar_section]
260\&... "bar" ENGINE specific commands ...
261.Ed
262.Pp
263The command
264.Ic engine_id
265is used to give the ENGINE name.
266If used this command must be first.
267For example:
268.Bd -literal -offset indent
269[engine_section]
270# This would normally handle an ENGINE named "foo"
271foo = foo_section
272
273[foo_section]
274# Override default name and use "myfoo" instead.
275engine_id = myfoo
276.Ed
277.Pp
278The command
279.Ic dynamic_path
280loads and adds an ENGINE from the given path.
281It is equivalent to sending the ctrls
282.Sy SO_PATH
283with the path argument followed by
284.Sy LIST_ADD
285with value 2 and
286.Sy LOAD
287to the dynamic ENGINE.
288If this is not the required behaviour then alternative ctrls can be sent
289directly to the dynamic ENGINE using ctrl commands.
290.Pp
291The command
292.Ic init
293determines whether to initialize the ENGINE.
294If the value is 0, the ENGINE will not be initialized.
295If it is 1, an attempt is made to initialized the ENGINE immediately.
296If the
297.Ic init
298command is not present, then an attempt will be made to initialize
299the ENGINE after all commands in its section have been processed.
300.Pp
301The command
302.Ic default_algorithms
303sets the default algorithms an ENGINE will supply using the functions
304.Xr ENGINE_set_default_string 3 .
305.Pp
306If the name matches none of the above command names it is assumed
307to be a ctrl command which is sent to the ENGINE.
308The value of the command is the argument to the ctrl command.
309If the value is the string
310.Cm EMPTY ,
311then no value is sent to the command.
312.Pp
313For example:
314.Bd -literal -offset indent
315[engine_section]
316# Configure ENGINE named "foo"
317foo = foo_section
318
319[foo_section]
320# Load engine from DSO
321dynamic_path = /some/path/fooengine.so
322# A foo specific ctrl.
323some_ctrl = some_value
324# Another ctrl that doesn't take a value.
325other_ctrl = EMPTY
326# Supply all default algorithms
327default_algorithms = ALL
328.Ed
329.Sh FILES
330.Bl -tag -width /etc/ssl/openssl.cnf -compact
331.It Pa /etc/ssl/openssl.cnf
332standard configuration file
333.El
334.Sh EXAMPLES
335Here is a sample configuration file using some of the features
336mentioned above:
337.Bd -literal -offset indent
338# This is the default section.
339HOME=/temp
340RANDFILE= ${ENV::HOME}/.rnd
341configdir=$ENV::HOME/config
342
343[ section_one ]
344# We are now in section one.
345
346# Quotes permit leading and trailing whitespace
347any = " any variable name "
348
349other = A string that can \e
350cover several lines \e
351by including \e\e characters
352
353message = Hello World\en
354
355[ section_two ]
356greeting = $section_one::message
357.Ed
358.Pp
359This next example shows how to expand environment variables safely.
360.Pp
361Suppose you want a variable called
362.Sy tmpfile
363to refer to a temporary filename.
364The directory it is placed in can determined by the
365.Ev TEMP
366or
367.Ev TMP
368environment variables but they may not be set to any value at all.
369If you just include the environment variable names and the variable
370doesn't exist then this will cause an error when an attempt is made to
371load the configuration file.
372By making use of the default section both values can be looked up with
373.Ev TEMP
374taking priority and
375.Pa /tmp
376used if neither is defined:
377.Bd -literal -offset indent
378TMP=/tmp
379# The above value is used if TMP isn't in the environment
380TEMP=$ENV::TMP
381# The above value is used if TEMP isn't in the environment
382tmpfile=${ENV::TEMP}/tmp.filename
383.Ed
384.Pp
385More complex OpenSSL library configuration.
386Add OID:
387.Bd -literal -offset indent
388# Default appname: should match "appname" parameter (if any)
389# supplied to CONF_modules_load_file et al.
390openssl_conf = openssl_conf_section
391
392[openssl_conf_section]
393# Configuration module list
394alg_section = evp_sect
395oid_section = new_oids
396
397[new_oids]
398# New OID, just short name
399newoid1 = 1.2.3.4.1
400# New OID shortname and long name
401newoid2 = New OID 2 long name, 1.2.3.4.2
402.Ed
403.Pp
404The above examples can be used with any application supporting library
405configuration if "openssl_conf" is modified to match the appropriate
406"appname".
407.Pp
408For example if the second sample file above is saved to "example.cnf"
409then the command line:
410.Pp
411.Dl OPENSSL_CONF=example.cnf openssl asn1parse -genstr OID:1.2.3.4.1
412.Pp
413will output:
414.Dl 0:d=0  hl=2 l=   4 prim: OBJECT            :newoid1
415.Pp
416showing that the OID "newoid1" has been added as "1.2.3.4.1".
417.Sh SEE ALSO
418.Xr openssl 1 ,
419.Xr CONF_modules_load_file 3 ,
420.Xr x509v3.cnf 5
421.Sh CAVEATS
422If a configuration file attempts to expand a variable that doesn't
423exist, then an error is flagged and the file will not load.
424This can also happen if an attempt is made to expand an environment
425variable that doesn't exist.
426For example, in a previous version of OpenSSL the default OpenSSL
427master configuration file used the value of
428.Ev HOME
429which may not be defined on non Unix systems and would cause an error.
430.Pp
431This can be worked around by including a default section to provide
432a default value: then if the environment lookup fails, the default
433value will be used instead.
434For this to work properly, the default value must be defined earlier
435in the configuration file than the expansion.
436See the
437.Sx EXAMPLES
438section for an example of how to do this.
439.Pp
440If the same variable is defined more than once in the same section,
441then all but the last value will be silently ignored.
442In certain circumstances such as with DNs, the same field may occur
443multiple times.
444This is usually worked around by ignoring any characters before an
445initial
446.Ql \&. ,
447for example:
448.Bd -literal -offset indent
4491.OU="My first OU"
4502.OU="My Second OU"
451.Ed
452.Sh BUGS
453Currently there is no way to include characters using the octal
454.Pf \e Ar nnn
455form.
456Strings are all NUL terminated, so NUL bytes cannot form part of
457the value.
458.Pp
459The escaping isn't quite right: if you want to use sequences like
460.Ql \en ,
461you can't use any quote escaping on the same line.
462.Pp
463Files are loaded in a single pass.
464This means that a variable expansion will only work if the variables
465referenced are defined earlier in the file.
466