summaryrefslogtreecommitdiff
path: root/lib/libcrypto/man/openssl.cnf.5
blob: d95ccdcfbffa61881312d1455d88b97d3a03c568 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
.\" $OpenBSD: openssl.cnf.5,v 1.4 2018/02/16 18:21:57 schwarze Exp $
.\" full merge up to: OpenSSL man5/config b53338cb Feb 28 12:30:28 2017 +0100
.\" selective merge up to: OpenSSL a8c5ed81 Jul 18 13:57:25 2017 -0400
.\"
.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
.\" Copyright (c) 1999, 2000, 2004, 2013, 2015, 2016, 2017 The OpenSSL Project.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\"
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\"
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in
.\"    the documentation and/or other materials provided with the
.\"    distribution.
.\"
.\" 3. All advertising materials mentioning features or use of this
.\"    software must display the following acknowledgment:
.\"    "This product includes software developed by the OpenSSL Project
.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
.\"
.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
.\"    endorse or promote products derived from this software without
.\"    prior written permission. For written permission, please contact
.\"    openssl-core@openssl.org.
.\"
.\" 5. Products derived from this software may not be called "OpenSSL"
.\"    nor may "OpenSSL" appear in their names without prior written
.\"    permission of the OpenSSL Project.
.\"
.\" 6. Redistributions of any form whatsoever must retain the following
.\"    acknowledgment:
.\"    "This product includes software developed by the OpenSSL Project
.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
.\" OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd $Mdocdate: February 16 2018 $
.Dt OPENSSL.CNF 5
.Os
.Sh NAME
.Nm openssl.cnf
.Nd OpenSSL configuration files
.Sh DESCRIPTION
The OpenSSL CONF library can be used to read configuration files; see
.Xr CONF_modules_load_file 3 .
It is used for the OpenSSL master configuration file
.Pa /etc/ssl/openssl.cnf
and in a few other places like
.Sy SPKAC
files and certificate extension files for the
.Xr openssl 1
.Cm x509
utility.
OpenSSL applications can also use the CONF library for their own
purposes.
.Pp
A configuration file is divided into a number of sections.
Each section starts with a line
.Bq Ar section_name
and ends when a new section is started or the end of the file is reached.
A section name can consist of alphanumeric characters and underscores.
.Pp
The first section of a configuration file is special and is referred to
as the
.Dq default section .
It is usually unnamed and extends from the start of file to the
first named section.
When a name is being looked up, it is first looked up in a named
section (if any) and then in the default section.
.Pp
The environment is mapped onto a section called
.Ic ENV .
.Pp
Comments can be included by preceding them with the
.Ql #
character.
.Pp
Each section in a configuration file consists of a number of name and
value pairs of the form
.Ar name Ns = Ns Ar value .
.Pp
The
.Ar name
string can contain any alphanumeric characters as well as a few
punctuation symbols such as
.Ql \&.
.Ql \&,
.Ql \&;
and
.Ql _ .
.Pp
The
.Ar value
string consists of the string following the
.Ql =
character until the end of the line with any leading and trailing
whitespace removed.
.Pp
The value string undergoes variable expansion.
This can be done by including substrings of the form
.Pf $ Ar name
or
.Pf $ Brq Ar name :
this will substitute the value of the named variable in the current
section.
It is also possible to substitute a value from another section using the
syntax
.Pf $ Ar section Ns :: Ns Ar name
or
.Pf $ Brq Ar section Ns :: Ns Ar name .
By using the form
.Pf $ Ic ENV Ns :: Ns Ar name ,
environment variables can be substituted.
It is also possible to assign values to environment variables by using
the name
.Ic ENV Ns :: Ns Ar name .
This will work if the program looks up environment variables using
the CONF library instead of calling
.Xr getenv 3
directly.
.Pp
It is possible to escape certain characters by using any kind of quote
or the
.Ql \e
character.
By making the last character of a line a
.Ql \e ,
a
.Ar value
string can be spread across multiple lines.
In addition the sequences
.Ql \en ,
.Ql \er ,
.Ql \eb ,
and
.Ql \et
are recognized.
.Sh OPENSSL LIBRARY CONFIGURATION
Applications can automatically configure certain aspects of OpenSSL
using the master OpenSSL configuration file, or optionally an
alternative configuration file.
The
.Xr openssl 1
utility includes this functionality: any sub command uses the master
OpenSSL configuration file unless an option is used in the sub command
to use an alternative configuration file.
.Pp
To enable library configuration, the default section needs to contain
an appropriate line which points to the main configuration section.
The default name is
.Ic openssl_conf ,
which is used by the
.Xr openssl 1
utility.
Other applications may use an alternative name such as
.Sy myapplication_conf .
All library configuration lines appear in the default section
at the start of the configuration file.
.Pp
The configuration section should consist of a set of name value pairs
which contain specific module configuration information.
The
.Ar name
represents the name of the configuration module.
The meaning of the
.Ar value
is module specific: it may, for example, represent a further
configuration section containing configuration module specific
information.
For example:
.Bd -literal -offset indent
# The following line must be in the default section.
openssl_conf = openssl_init

[openssl_init]
oid_section = new_oids
engines = engine_section

[new_oids]
\&... new oids here ...

[engine_section]
\&... engine stuff here ...
.Ed
.Pp
The features of each configuration module are described below.
.Ss ASN1 Object Configuration Module
This module has the name
.Ic oid_section .
The value of this variable points to a section containing name value
pairs of OIDs: the name is the OID short and long name, and the value is the
numerical form of the OID.
Although some of the
.Xr openssl 1
utility subcommands already have their own ASN1 OBJECT section
functionality, not all do.
By using the ASN1 OBJECT configuration module, all the
.Xr openssl 1
utility subcommands can see the new objects as well as any compliant
applications.
For example:
.Bd -literal -offset indent
[new_oids]
some_new_oid = 1.2.3.4
some_other_oid = 1.2.3.5
.Ed
.Pp
It is also possible to set the value to the long name followed by a
comma and the numerical OID form.
For example:
.Pp
.Dl shortName = some object long name, 1.2.3.4
.Ss Engine Configuration Module
This ENGINE configuration module has the name
.Ic engines .
The value of this variable points to a section containing further ENGINE
configuration information.
.Pp
The section pointed to by
.Ic engines
is a table of engine names (though see
.Ic engine_id
below) and further sections containing configuration information
specific to each ENGINE.
.Pp
Each ENGINE specific section is used to set default algorithms, load
dynamic ENGINEs, perform initialization and send ctrls.
The actual operation performed depends on the command
name which is the name of the name value pair.
The currently supported commands are listed below.
.Pp
For example:
.Bd -literal -offset indent
[engine_section]
# Configure ENGINE named "foo"
foo = foo_section
# Configure ENGINE named "bar"
bar = bar_section

[foo_section]
\&... foo ENGINE specific commands ...

[bar_section]
\&... "bar" ENGINE specific commands ...
.Ed
.Pp
The command
.Ic engine_id
is used to give the ENGINE name.
If used this command must be first.
For example:
.Bd -literal -offset indent
[engine_section]
# This would normally handle an ENGINE named "foo"
foo = foo_section

[foo_section]
# Override default name and use "myfoo" instead.
engine_id = myfoo
.Ed
.Pp
The command
.Ic dynamic_path
loads and adds an ENGINE from the given path.
It is equivalent to sending the ctrls
.Sy SO_PATH
with the path argument followed by
.Sy LIST_ADD
with value 2 and
.Sy LOAD
to the dynamic ENGINE.
If this is not the required behaviour then alternative ctrls can be sent
directly to the dynamic ENGINE using ctrl commands.
.Pp
The command
.Ic init
determines whether to initialize the ENGINE.
If the value is 0, the ENGINE will not be initialized.
If it is 1, an attempt is made to initialized the ENGINE immediately.
If the
.Ic init
command is not present, then an attempt will be made to initialize
the ENGINE after all commands in its section have been processed.
.Pp
The command
.Ic default_algorithms
sets the default algorithms an ENGINE will supply using the functions
.Xr ENGINE_set_default_string 3 .
.Pp
If the name matches none of the above command names it is assumed
to be a ctrl command which is sent to the ENGINE.
The value of the command is the argument to the ctrl command.
If the value is the string
.Cm EMPTY ,
then no value is sent to the command.
.Pp
For example:
.Bd -literal -offset indent
[engine_section]
# Configure ENGINE named "foo"
foo = foo_section

[foo_section]
# Load engine from DSO
dynamic_path = /some/path/fooengine.so
# A foo specific ctrl.
some_ctrl = some_value
# Another ctrl that doesn't take a value.
other_ctrl = EMPTY
# Supply all default algorithms
default_algorithms = ALL
.Ed
.Sh FILES
.Bl -tag -width /etc/ssl/openssl.cnf -compact
.It Pa /etc/ssl/openssl.cnf
standard configuration file
.El
.Sh EXAMPLES
Here is a sample configuration file using some of the features
mentioned above:
.Bd -literal -offset indent
# This is the default section.
HOME=/temp
RANDFILE= ${ENV::HOME}/.rnd
configdir=$ENV::HOME/config

[ section_one ]
# We are now in section one.

# Quotes permit leading and trailing whitespace
any = " any variable name "

other = A string that can \e
cover several lines \e
by including \e\e characters

message = Hello World\en

[ section_two ]
greeting = $section_one::message
.Ed
.Pp
This next example shows how to expand environment variables safely.
.Pp
Suppose you want a variable called
.Sy tmpfile
to refer to a temporary filename.
The directory it is placed in can determined by the
.Ev TEMP
or
.Ev TMP
environment variables but they may not be set to any value at all.
If you just include the environment variable names and the variable
doesn't exist then this will cause an error when an attempt is made to
load the configuration file.
By making use of the default section both values can be looked up with
.Ev TEMP
taking priority and
.Pa /tmp
used if neither is defined:
.Bd -literal -offset indent
TMP=/tmp
# The above value is used if TMP isn't in the environment
TEMP=$ENV::TMP
# The above value is used if TEMP isn't in the environment
tmpfile=${ENV::TEMP}/tmp.filename
.Ed
.Pp
More complex OpenSSL library configuration.
Add OID:
.Bd -literal -offset indent
# Default appname: should match "appname" parameter (if any)
# supplied to CONF_modules_load_file et al.
openssl_conf = openssl_conf_section

[openssl_conf_section]
# Configuration module list
alg_section = evp_sect
oid_section = new_oids

[new_oids]
# New OID, just short name
newoid1 = 1.2.3.4.1
# New OID shortname and long name
newoid2 = New OID 2 long name, 1.2.3.4.2
.Ed
.Pp
The above examples can be used with any application supporting library
configuration if "openssl_conf" is modified to match the appropriate
"appname".
.Pp
For example if the second sample file above is saved to "example.cnf"
then the command line:
.Pp
.Dl OPENSSL_CONF=example.cnf openssl asn1parse -genstr OID:1.2.3.4.1
.Pp
will output:
.Dl 0:d=0  hl=2 l=   4 prim: OBJECT            :newoid1
.Pp
showing that the OID "newoid1" has been added as "1.2.3.4.1".
.Sh SEE ALSO
.Xr openssl 1 ,
.Xr CONF_modules_load_file 3 ,
.Xr x509v3.cnf 5
.Sh CAVEATS
If a configuration file attempts to expand a variable that doesn't
exist, then an error is flagged and the file will not load.
This can also happen if an attempt is made to expand an environment
variable that doesn't exist.
For example, in a previous version of OpenSSL the default OpenSSL
master configuration file used the value of
.Ev HOME
which may not be defined on non Unix systems and would cause an error.
.Pp
This can be worked around by including a default section to provide
a default value: then if the environment lookup fails, the default
value will be used instead.
For this to work properly, the default value must be defined earlier
in the configuration file than the expansion.
See the
.Sx EXAMPLES
section for an example of how to do this.
.Pp
If the same variable is defined more than once in the same section,
then all but the last value will be silently ignored.
In certain circumstances such as with DNs, the same field may occur
multiple times.
This is usually worked around by ignoring any characters before an
initial
.Ql \&. ,
for example:
.Bd -literal -offset indent
1.OU="My first OU"
2.OU="My Second OU"
.Ed
.Sh BUGS
Currently there is no way to include characters using the octal
.Pf \e Ar nnn
form.
Strings are all NUL terminated, so NUL bytes cannot form part of
the value.
.Pp
The escaping isn't quite right: if you want to use sequences like
.Ql \en ,
you can't use any quote escaping on the same line.
.Pp
Files are loaded in a single pass.
This means that an variable expansion will only work if the variables
referenced are defined earlier in the file.