xref: /minix3/crypto/external/bsd/openssl/dist/doc/apps/config.pod (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1ebfedea0SLionel Sambuc
2ebfedea0SLionel Sambuc=pod
3ebfedea0SLionel Sambuc
4ebfedea0SLionel Sambuc=for comment openssl_manual_section:5
5ebfedea0SLionel Sambuc
6ebfedea0SLionel Sambuc=head1 NAME
7ebfedea0SLionel Sambuc
8ebfedea0SLionel Sambucconfig - OpenSSL CONF library configuration files
9ebfedea0SLionel Sambuc
10ebfedea0SLionel Sambuc=head1 DESCRIPTION
11ebfedea0SLionel Sambuc
12ebfedea0SLionel SambucThe OpenSSL CONF library can be used to read configuration files.
13ebfedea0SLionel SambucIt is used for the OpenSSL master configuration file B<openssl.cnf>
14ebfedea0SLionel Sambucand in a few other places like B<SPKAC> files and certificate extension
15ebfedea0SLionel Sambucfiles for the B<x509> utility. OpenSSL applications can also use the
16ebfedea0SLionel SambucCONF library for their own purposes.
17ebfedea0SLionel Sambuc
18ebfedea0SLionel SambucA configuration file is divided into a number of sections. Each section
19ebfedea0SLionel Sambucstarts with a line B<[ section_name ]> and ends when a new section is
20ebfedea0SLionel Sambucstarted or end of file is reached. A section name can consist of
21ebfedea0SLionel Sambucalphanumeric characters and underscores.
22ebfedea0SLionel Sambuc
23ebfedea0SLionel SambucThe first section of a configuration file is special and is referred
24ebfedea0SLionel Sambucto as the B<default> section this is usually unnamed and is from the
25ebfedea0SLionel Sambucstart of file until the first named section. When a name is being looked up
26ebfedea0SLionel Sambucit is first looked up in a named section (if any) and then the
27ebfedea0SLionel Sambucdefault section.
28ebfedea0SLionel Sambuc
29ebfedea0SLionel SambucThe environment is mapped onto a section called B<ENV>.
30ebfedea0SLionel Sambuc
31ebfedea0SLionel SambucComments can be included by preceding them with the B<#> character
32ebfedea0SLionel Sambuc
33ebfedea0SLionel SambucEach section in a configuration file consists of a number of name and
34ebfedea0SLionel Sambucvalue pairs of the form B<name=value>
35ebfedea0SLionel Sambuc
36ebfedea0SLionel SambucThe B<name> string can contain any alphanumeric characters as well as
37ebfedea0SLionel Sambuca few punctuation symbols such as B<.> B<,> B<;> and B<_>.
38ebfedea0SLionel Sambuc
39ebfedea0SLionel SambucThe B<value> string consists of the string following the B<=> character
40ebfedea0SLionel Sambucuntil end of line with any leading and trailing white space removed.
41ebfedea0SLionel Sambuc
42ebfedea0SLionel SambucThe value string undergoes variable expansion. This can be done by
43ebfedea0SLionel Sambucincluding the form B<$var> or B<${var}>: this will substitute the value
44ebfedea0SLionel Sambucof the named variable in the current section. It is also possible to
45ebfedea0SLionel Sambucsubstitute a value from another section using the syntax B<$section::name>
46ebfedea0SLionel Sambucor B<${section::name}>. By using the form B<$ENV::name> environment
47ebfedea0SLionel Sambucvariables can be substituted. It is also possible to assign values to
48ebfedea0SLionel Sambucenvironment variables by using the name B<ENV::name>, this will work
49ebfedea0SLionel Sambucif the program looks up environment variables using the B<CONF> library
50ebfedea0SLionel Sambucinstead of calling B<getenv()> directly.
51ebfedea0SLionel Sambuc
52ebfedea0SLionel SambucIt is possible to escape certain characters by using any kind of quote
53ebfedea0SLionel Sambucor the B<\> character. By making the last character of a line a B<\>
54ebfedea0SLionel Sambuca B<value> string can be spread across multiple lines. In addition
55ebfedea0SLionel Sambucthe sequences B<\n>, B<\r>, B<\b> and B<\t> are recognized.
56ebfedea0SLionel Sambuc
57ebfedea0SLionel Sambuc=head1 OPENSSL LIBRARY CONFIGURATION
58ebfedea0SLionel Sambuc
59ebfedea0SLionel SambucIn OpenSSL 0.9.7 and later applications can automatically configure certain
60ebfedea0SLionel Sambucaspects of OpenSSL using the master OpenSSL configuration file, or optionally
61ebfedea0SLionel Sambucan alternative configuration file. The B<openssl> utility includes this
62ebfedea0SLionel Sambucfunctionality: any sub command uses the master OpenSSL configuration file
63ebfedea0SLionel Sambucunless an option is used in the sub command to use an alternative configuration
64ebfedea0SLionel Sambucfile.
65ebfedea0SLionel Sambuc
66ebfedea0SLionel SambucTo enable library configuration the default section needs to contain an
67ebfedea0SLionel Sambucappropriate line which points to the main configuration section. The default
68ebfedea0SLionel Sambucname is B<openssl_conf> which is used by the B<openssl> utility. Other
69ebfedea0SLionel Sambucapplications may use an alternative name such as B<myapplicaton_conf>.
70ebfedea0SLionel Sambuc
71ebfedea0SLionel SambucThe configuration section should consist of a set of name value pairs which
72ebfedea0SLionel Sambuccontain specific module configuration information. The B<name> represents
73ebfedea0SLionel Sambucthe name of the I<configuration module> the meaning of the B<value> is
74ebfedea0SLionel Sambucmodule specific: it may, for example, represent a further configuration
75ebfedea0SLionel Sambucsection containing configuration module specific information. E.g.
76ebfedea0SLionel Sambuc
77ebfedea0SLionel Sambuc openssl_conf = openssl_init
78ebfedea0SLionel Sambuc
79ebfedea0SLionel Sambuc [openssl_init]
80ebfedea0SLionel Sambuc
81ebfedea0SLionel Sambuc oid_section = new_oids
82ebfedea0SLionel Sambuc engines = engine_section
83ebfedea0SLionel Sambuc
84ebfedea0SLionel Sambuc [new_oids]
85ebfedea0SLionel Sambuc
86ebfedea0SLionel Sambuc ... new oids here ...
87ebfedea0SLionel Sambuc
88ebfedea0SLionel Sambuc [engine_section]
89ebfedea0SLionel Sambuc
90ebfedea0SLionel Sambuc ... engine stuff here ...
91ebfedea0SLionel Sambuc
92*0a6a1f1dSLionel SambucThe features of each configuration module are described below.
93ebfedea0SLionel Sambuc
94ebfedea0SLionel Sambuc=head2 ASN1 OBJECT CONFIGURATION MODULE
95ebfedea0SLionel Sambuc
96ebfedea0SLionel SambucThis module has the name B<oid_section>. The value of this variable points
97ebfedea0SLionel Sambucto a section containing name value pairs of OIDs: the name is the OID short
98ebfedea0SLionel Sambucand long name, the value is the numerical form of the OID. Although some of
99ebfedea0SLionel Sambucthe B<openssl> utility sub commands already have their own ASN1 OBJECT section
100ebfedea0SLionel Sambucfunctionality not all do. By using the ASN1 OBJECT configuration module
101ebfedea0SLionel SambucB<all> the B<openssl> utility sub commands can see the new objects as well
102ebfedea0SLionel Sambucas any compliant applications. For example:
103ebfedea0SLionel Sambuc
104ebfedea0SLionel Sambuc [new_oids]
105ebfedea0SLionel Sambuc
106ebfedea0SLionel Sambuc some_new_oid = 1.2.3.4
107ebfedea0SLionel Sambuc some_other_oid = 1.2.3.5
108ebfedea0SLionel Sambuc
109ebfedea0SLionel SambucIn OpenSSL 0.9.8 it is also possible to set the value to the long name followed
110ebfedea0SLionel Sambucby a comma and the numerical OID form. For example:
111ebfedea0SLionel Sambuc
112ebfedea0SLionel Sambuc shortName = some object long name, 1.2.3.4
113ebfedea0SLionel Sambuc
114ebfedea0SLionel Sambuc=head2 ENGINE CONFIGURATION MODULE
115ebfedea0SLionel Sambuc
116ebfedea0SLionel SambucThis ENGINE configuration module has the name B<engines>. The value of this
117ebfedea0SLionel Sambucvariable points to a section containing further ENGINE configuration
118ebfedea0SLionel Sambucinformation.
119ebfedea0SLionel Sambuc
120ebfedea0SLionel SambucThe section pointed to by B<engines> is a table of engine names (though see
121*0a6a1f1dSLionel SambucB<engine_id> below) and further sections containing configuration information
122ebfedea0SLionel Sambucspecific to each ENGINE.
123ebfedea0SLionel Sambuc
124ebfedea0SLionel SambucEach ENGINE specific section is used to set default algorithms, load
125ebfedea0SLionel Sambucdynamic, perform initialization and send ctrls. The actual operation performed
126ebfedea0SLionel Sambucdepends on the I<command> name which is the name of the name value pair. The
127ebfedea0SLionel Sambuccurrently supported commands are listed below.
128ebfedea0SLionel Sambuc
129ebfedea0SLionel SambucFor example:
130ebfedea0SLionel Sambuc
131ebfedea0SLionel Sambuc [engine_section]
132ebfedea0SLionel Sambuc
133ebfedea0SLionel Sambuc # Configure ENGINE named "foo"
134ebfedea0SLionel Sambuc foo = foo_section
135ebfedea0SLionel Sambuc # Configure ENGINE named "bar"
136ebfedea0SLionel Sambuc bar = bar_section
137ebfedea0SLionel Sambuc
138ebfedea0SLionel Sambuc [foo_section]
139ebfedea0SLionel Sambuc ... foo ENGINE specific commands ...
140ebfedea0SLionel Sambuc
141ebfedea0SLionel Sambuc [bar_section]
142ebfedea0SLionel Sambuc ... "bar" ENGINE specific commands ...
143ebfedea0SLionel Sambuc
144ebfedea0SLionel SambucThe command B<engine_id> is used to give the ENGINE name. If used this
145ebfedea0SLionel Sambuccommand must be first. For example:
146ebfedea0SLionel Sambuc
147ebfedea0SLionel Sambuc [engine_section]
148ebfedea0SLionel Sambuc # This would normally handle an ENGINE named "foo"
149ebfedea0SLionel Sambuc foo = foo_section
150ebfedea0SLionel Sambuc
151ebfedea0SLionel Sambuc [foo_section]
152ebfedea0SLionel Sambuc # Override default name and use "myfoo" instead.
153ebfedea0SLionel Sambuc engine_id = myfoo
154ebfedea0SLionel Sambuc
155ebfedea0SLionel SambucThe command B<dynamic_path> loads and adds an ENGINE from the given path. It
156ebfedea0SLionel Sambucis equivalent to sending the ctrls B<SO_PATH> with the path argument followed
157ebfedea0SLionel Sambucby B<LIST_ADD> with value 2 and B<LOAD> to the dynamic ENGINE. If this is
158ebfedea0SLionel Sambucnot the required behaviour then alternative ctrls can be sent directly
159ebfedea0SLionel Sambucto the dynamic ENGINE using ctrl commands.
160ebfedea0SLionel Sambuc
161ebfedea0SLionel SambucThe command B<init> determines whether to initialize the ENGINE. If the value
162ebfedea0SLionel Sambucis B<0> the ENGINE will not be initialized, if B<1> and attempt it made to
163ebfedea0SLionel Sambucinitialized the ENGINE immediately. If the B<init> command is not present
164ebfedea0SLionel Sambucthen an attempt will be made to initialize the ENGINE after all commands in
165ebfedea0SLionel Sambucits section have been processed.
166ebfedea0SLionel Sambuc
167ebfedea0SLionel SambucThe command B<default_algorithms> sets the default algorithms an ENGINE will
168ebfedea0SLionel Sambucsupply using the functions B<ENGINE_set_default_string()>
169ebfedea0SLionel Sambuc
170ebfedea0SLionel SambucIf the name matches none of the above command names it is assumed to be a
171ebfedea0SLionel Sambucctrl command which is sent to the ENGINE. The value of the command is the
172ebfedea0SLionel Sambucargument to the ctrl command. If the value is the string B<EMPTY> then no
173ebfedea0SLionel Sambucvalue is sent to the command.
174ebfedea0SLionel Sambuc
175ebfedea0SLionel SambucFor example:
176ebfedea0SLionel Sambuc
177ebfedea0SLionel Sambuc
178ebfedea0SLionel Sambuc [engine_section]
179ebfedea0SLionel Sambuc
180ebfedea0SLionel Sambuc # Configure ENGINE named "foo"
181ebfedea0SLionel Sambuc foo = foo_section
182ebfedea0SLionel Sambuc
183ebfedea0SLionel Sambuc [foo_section]
184ebfedea0SLionel Sambuc # Load engine from DSO
185ebfedea0SLionel Sambuc dynamic_path = /some/path/fooengine.so
186ebfedea0SLionel Sambuc # A foo specific ctrl.
187ebfedea0SLionel Sambuc some_ctrl = some_value
188ebfedea0SLionel Sambuc # Another ctrl that doesn't take a value.
189ebfedea0SLionel Sambuc other_ctrl = EMPTY
190ebfedea0SLionel Sambuc # Supply all default algorithms
191ebfedea0SLionel Sambuc default_algorithms = ALL
192ebfedea0SLionel Sambuc
193*0a6a1f1dSLionel Sambuc=head2 EVP CONFIGURATION MODULE
194*0a6a1f1dSLionel Sambuc
195*0a6a1f1dSLionel SambucThis modules has the name B<alg_section> which points to a section containing
196*0a6a1f1dSLionel Sambucalgorithm commands.
197*0a6a1f1dSLionel Sambuc
198*0a6a1f1dSLionel SambucCurrently the only algorithm command supported is B<fips_mode> whose
199*0a6a1f1dSLionel Sambucvalue should be a boolean string such as B<on> or B<off>. If the value is
200*0a6a1f1dSLionel SambucB<on> this attempt to enter FIPS mode. If the call fails or the library is
201*0a6a1f1dSLionel Sambucnot FIPS capable then an error occurs.
202*0a6a1f1dSLionel Sambuc
203*0a6a1f1dSLionel SambucFor example:
204*0a6a1f1dSLionel Sambuc
205*0a6a1f1dSLionel Sambuc alg_section = evp_settings
206*0a6a1f1dSLionel Sambuc
207*0a6a1f1dSLionel Sambuc [evp_settings]
208*0a6a1f1dSLionel Sambuc
209*0a6a1f1dSLionel Sambuc fips_mode = on
210*0a6a1f1dSLionel Sambuc
211*0a6a1f1dSLionel Sambuc
212ebfedea0SLionel Sambuc=head1 NOTES
213ebfedea0SLionel Sambuc
214ebfedea0SLionel SambucIf a configuration file attempts to expand a variable that doesn't exist
215ebfedea0SLionel Sambucthen an error is flagged and the file will not load. This can happen
216ebfedea0SLionel Sambucif an attempt is made to expand an environment variable that doesn't
217ebfedea0SLionel Sambucexist. For example in a previous version of OpenSSL the default OpenSSL
218ebfedea0SLionel Sambucmaster configuration file used the value of B<HOME> which may not be
219ebfedea0SLionel Sambucdefined on non Unix systems and would cause an error.
220ebfedea0SLionel Sambuc
221ebfedea0SLionel SambucThis can be worked around by including a B<default> section to provide
222ebfedea0SLionel Sambuca default value: then if the environment lookup fails the default value
223ebfedea0SLionel Sambucwill be used instead. For this to work properly the default value must
224ebfedea0SLionel Sambucbe defined earlier in the configuration file than the expansion. See
225ebfedea0SLionel Sambucthe B<EXAMPLES> section for an example of how to do this.
226ebfedea0SLionel Sambuc
227ebfedea0SLionel SambucIf the same variable exists in the same section then all but the last
228ebfedea0SLionel Sambucvalue will be silently ignored. In certain circumstances such as with
229ebfedea0SLionel SambucDNs the same field may occur multiple times. This is usually worked
230ebfedea0SLionel Sambucaround by ignoring any characters before an initial B<.> e.g.
231ebfedea0SLionel Sambuc
232ebfedea0SLionel Sambuc 1.OU="My first OU"
233ebfedea0SLionel Sambuc 2.OU="My Second OU"
234ebfedea0SLionel Sambuc
235ebfedea0SLionel Sambuc=head1 EXAMPLES
236ebfedea0SLionel Sambuc
237ebfedea0SLionel SambucHere is a sample configuration file using some of the features
238ebfedea0SLionel Sambucmentioned above.
239ebfedea0SLionel Sambuc
240ebfedea0SLionel Sambuc # This is the default section.
241ebfedea0SLionel Sambuc
242ebfedea0SLionel Sambuc HOME=/temp
243ebfedea0SLionel Sambuc RANDFILE= ${ENV::HOME}/.rnd
244ebfedea0SLionel Sambuc configdir=$ENV::HOME/config
245ebfedea0SLionel Sambuc
246ebfedea0SLionel Sambuc [ section_one ]
247ebfedea0SLionel Sambuc
248ebfedea0SLionel Sambuc # We are now in section one.
249ebfedea0SLionel Sambuc
250ebfedea0SLionel Sambuc # Quotes permit leading and trailing whitespace
251ebfedea0SLionel Sambuc any = " any variable name "
252ebfedea0SLionel Sambuc
253ebfedea0SLionel Sambuc other = A string that can \
254ebfedea0SLionel Sambuc cover several lines \
255ebfedea0SLionel Sambuc by including \\ characters
256ebfedea0SLionel Sambuc
257ebfedea0SLionel Sambuc message = Hello World\n
258ebfedea0SLionel Sambuc
259ebfedea0SLionel Sambuc [ section_two ]
260ebfedea0SLionel Sambuc
261ebfedea0SLionel Sambuc greeting = $section_one::message
262ebfedea0SLionel Sambuc
263ebfedea0SLionel SambucThis next example shows how to expand environment variables safely.
264ebfedea0SLionel Sambuc
265ebfedea0SLionel SambucSuppose you want a variable called B<tmpfile> to refer to a
266ebfedea0SLionel Sambuctemporary filename. The directory it is placed in can determined by
267ebfedea0SLionel Sambucthe the B<TEMP> or B<TMP> environment variables but they may not be
268ebfedea0SLionel Sambucset to any value at all. If you just include the environment variable
269ebfedea0SLionel Sambucnames and the variable doesn't exist then this will cause an error when
270ebfedea0SLionel Sambucan attempt is made to load the configuration file. By making use of the
271ebfedea0SLionel Sambucdefault section both values can be looked up with B<TEMP> taking
272ebfedea0SLionel Sambucpriority and B</tmp> used if neither is defined:
273ebfedea0SLionel Sambuc
274ebfedea0SLionel Sambuc TMP=/tmp
275ebfedea0SLionel Sambuc # The above value is used if TMP isn't in the environment
276ebfedea0SLionel Sambuc TEMP=$ENV::TMP
277ebfedea0SLionel Sambuc # The above value is used if TEMP isn't in the environment
278ebfedea0SLionel Sambuc tmpfile=${ENV::TEMP}/tmp.filename
279ebfedea0SLionel Sambuc
280*0a6a1f1dSLionel SambucSimple OpenSSL library configuration example to enter FIPS mode:
281*0a6a1f1dSLionel Sambuc
282*0a6a1f1dSLionel Sambuc # Default appname: should match "appname" parameter (if any)
283*0a6a1f1dSLionel Sambuc # supplied to CONF_modules_load_file et al.
284*0a6a1f1dSLionel Sambuc openssl_conf = openssl_conf_section
285*0a6a1f1dSLionel Sambuc
286*0a6a1f1dSLionel Sambuc [openssl_conf_section]
287*0a6a1f1dSLionel Sambuc # Configuration module list
288*0a6a1f1dSLionel Sambuc alg_section = evp_sect
289*0a6a1f1dSLionel Sambuc
290*0a6a1f1dSLionel Sambuc [evp_sect]
291*0a6a1f1dSLionel Sambuc # Set to "yes" to enter FIPS mode if supported
292*0a6a1f1dSLionel Sambuc fips_mode = yes
293*0a6a1f1dSLionel Sambuc
294*0a6a1f1dSLionel SambucNote: in the above example you will get an error in non FIPS capable versions
295*0a6a1f1dSLionel Sambucof OpenSSL.
296*0a6a1f1dSLionel Sambuc
297*0a6a1f1dSLionel SambucMore complex OpenSSL library configuration. Add OID and don't enter FIPS mode:
298*0a6a1f1dSLionel Sambuc
299*0a6a1f1dSLionel Sambuc # Default appname: should match "appname" parameter (if any)
300*0a6a1f1dSLionel Sambuc # supplied to CONF_modules_load_file et al.
301*0a6a1f1dSLionel Sambuc openssl_conf = openssl_conf_section
302*0a6a1f1dSLionel Sambuc
303*0a6a1f1dSLionel Sambuc [openssl_conf_section]
304*0a6a1f1dSLionel Sambuc # Configuration module list
305*0a6a1f1dSLionel Sambuc alg_section = evp_sect
306*0a6a1f1dSLionel Sambuc oid_section = new_oids
307*0a6a1f1dSLionel Sambuc
308*0a6a1f1dSLionel Sambuc [evp_sect]
309*0a6a1f1dSLionel Sambuc # This will have no effect as FIPS mode is off by default.
310*0a6a1f1dSLionel Sambuc # Set to "yes" to enter FIPS mode, if supported
311*0a6a1f1dSLionel Sambuc fips_mode = no
312*0a6a1f1dSLionel Sambuc
313*0a6a1f1dSLionel Sambuc [new_oids]
314*0a6a1f1dSLionel Sambuc # New OID, just short name
315*0a6a1f1dSLionel Sambuc newoid1 = 1.2.3.4.1
316*0a6a1f1dSLionel Sambuc # New OID shortname and long name
317*0a6a1f1dSLionel Sambuc newoid2 = New OID 2 long name, 1.2.3.4.2
318*0a6a1f1dSLionel Sambuc
319*0a6a1f1dSLionel SambucThe above examples can be used with with any application supporting library
320*0a6a1f1dSLionel Sambucconfiguration if "openssl_conf" is modified to match the appropriate "appname".
321*0a6a1f1dSLionel Sambuc
322*0a6a1f1dSLionel SambucFor example if the second sample file above is saved to "example.cnf" then
323*0a6a1f1dSLionel Sambucthe command line:
324*0a6a1f1dSLionel Sambuc
325*0a6a1f1dSLionel Sambuc OPENSSL_CONF=example.cnf openssl asn1parse -genstr OID:1.2.3.4.1
326*0a6a1f1dSLionel Sambuc
327*0a6a1f1dSLionel Sambucwill output:
328*0a6a1f1dSLionel Sambuc
329*0a6a1f1dSLionel Sambuc    0:d=0  hl=2 l=   4 prim: OBJECT            :newoid1
330*0a6a1f1dSLionel Sambuc
331*0a6a1f1dSLionel Sambucshowing that the OID "newoid1" has been added as "1.2.3.4.1".
332*0a6a1f1dSLionel Sambuc
333ebfedea0SLionel Sambuc=head1 BUGS
334ebfedea0SLionel Sambuc
335ebfedea0SLionel SambucCurrently there is no way to include characters using the octal B<\nnn>
336ebfedea0SLionel Sambucform. Strings are all null terminated so nulls cannot form part of
337ebfedea0SLionel Sambucthe value.
338ebfedea0SLionel Sambuc
339ebfedea0SLionel SambucThe escaping isn't quite right: if you want to use sequences like B<\n>
340ebfedea0SLionel Sambucyou can't use any quote escaping on the same line.
341ebfedea0SLionel Sambuc
342ebfedea0SLionel SambucFiles are loaded in a single pass. This means that an variable expansion
343ebfedea0SLionel Sambucwill only work if the variables referenced are defined earlier in the
344ebfedea0SLionel Sambucfile.
345ebfedea0SLionel Sambuc
346ebfedea0SLionel Sambuc=head1 SEE ALSO
347ebfedea0SLionel Sambuc
348ebfedea0SLionel SambucL<x509(1)|x509(1)>, L<req(1)|req(1)>, L<ca(1)|ca(1)>
349ebfedea0SLionel Sambuc
350ebfedea0SLionel Sambuc=cut
351