2
0

config.pod 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. =pod
  2. =head1 NAME
  3. config - OpenSSL CONF library configuration files
  4. =head1 DESCRIPTION
  5. This page documents the syntax of OpenSSL configuration files,
  6. as parsed by L<NCONF_load(3)> and related functions.
  7. This format is used by many of the OpenSSL commands, and to
  8. initialize the libraries when used by any application.
  9. The first part describes the general syntax of the configuration
  10. files, and subsequent sections describe the semantics of individual
  11. modules. Other modules are described in L<fips_config(5)> and
  12. L<x509v3_config(5)>.
  13. The syntax for defining ASN.1 values is described in
  14. L<ASN1_generate_nconf(3)>.
  15. =head1 SYNTAX
  16. A configuration file is a series of lines. Blank lines, and whitespace
  17. between the elements of a line, have no significance. A comment starts
  18. with a B<#> character; the rest of the line is ignored. If the B<#>
  19. is the first non-space character in a line, the entire line is ignored.
  20. =head2 Directives
  21. Two directives can be used to control the parsing of configuration files:
  22. B<.include> and B<.pragma>.
  23. For compatibility with older versions of OpenSSL, an equal sign after the
  24. directive will be ignored. Older versions will treat it as an assignment,
  25. so care should be taken if the difference in semantics is important.
  26. A file can include other files using the include syntax:
  27. .include [=] pathname
  28. If B<pathname> is a simple filename, that file is included directly at
  29. that point. Included files can have B<.include> statements that specify
  30. other files. If B<pathname> is a directory, all files within that directory
  31. that have a C<.cnf> or C<.conf> extension will be included. (This is only
  32. available on systems with POSIX IO support.) Any sub-directories found
  33. inside the B<pathname> are B<ignored>. Similarly, if a file is opened
  34. while scanning a directory, and that file has an B<.include> directive
  35. that specifies a directory, that is also ignored.
  36. As a general rule, the B<pathname> should be an absolute path; this can
  37. be enforced with the B<abspath> and B<includedir> pragmas, described below.
  38. The environment variable B<OPENSSL_CONF_INCLUDE>, if it exists,
  39. is prepended to all relative pathnames.
  40. If the pathname is still relative, it is interpreted based on the
  41. current working directory.
  42. To require all file inclusions to name absolute paths, use the following
  43. directive:
  44. .pragma [=] abspath:value
  45. The default behavior, where the B<value> is B<false> or B<off>, is to allow
  46. relative paths. To require all B<.include> pathnames to be absolute paths,
  47. use a B<value> of B<true> or B<on>.
  48. In these files, the dollar sign, B<$>, is used to reference a variable, as
  49. described below. On some platforms, however, it is common to treat B<$>
  50. as a regular character in symbol names. Supporting this behavior can be
  51. done with the following directive:
  52. .pragma [=] dollarid:value
  53. The default behavior, where the B<value> is B<false> or B<off>, is to treat
  54. the dollarsign as indicating a variable name; C<foo$bar> is interpreted as
  55. C<foo> followed by the expansion of the variable C<bar>. If B<value> is
  56. B<true> or B<on>, then C<foo$bar> is a single seven-character name nad
  57. variable expansions must be specified using braces or parentheses.
  58. .pragma [=] includedir:value
  59. If a relative pathname is specified in the B<.include> directive, and
  60. the B<OPENSSL_CONF_INCLUDE> environment variable doesn't exist, then
  61. the value of the B<includedir> pragma, if it exists, is prepended to the
  62. pathname.
  63. =head2 Settings
  64. A configuration file is divided into a number of I<sections>. A section
  65. begins with the section name in square brackets, and ends when a new
  66. section starts, or at the end of the file. The section name can consist
  67. of alphanumeric characters and underscores.
  68. Whitespace between the name and the brackets is removed.
  69. The first section of a configuration file is special and is referred to
  70. as the B<default> section. This section is usually unnamed and spans from
  71. the start of file until the first named section. When a name is being
  72. looked up, it is first looked up in the current or named section,
  73. and then the default section if necessary.
  74. The environment is mapped onto a section called B<ENV>.
  75. Within a section are a series of name/value assignments, described in more
  76. detail below. As a reminder, the square brackets shown in this example
  77. are required, not optional:
  78. [ section ]
  79. name1 = This is value1
  80. name2 = Another value
  81. ...
  82. [ newsection ]
  83. name1 = New value1
  84. name3 = Value 3
  85. The B<name> can contain any alphanumeric characters as well as a few
  86. punctuation symbols such as B<.> B<,> B<;> and B<_>.
  87. Whitespace after the name and before the equal sign is ignored.
  88. If a name is repeated in the same section, then all but the last
  89. value are ignored. In certain circumstances, such as with
  90. Certificate DNs, the same field may occur multiple times.
  91. In order to support this, commands like L<openssl-req(1)> ignore any
  92. leading text that is preceded with a period. For example:
  93. 1.OU = First OU
  94. 2.OU = Second OU
  95. The B<value> consists of the string following the B<=> character until end
  96. of line with any leading and trailing whitespace removed.
  97. The value string undergoes variable expansion. The text C<$var> or C<${var}>
  98. inserts the value of the named variable from the current section.
  99. To use a value from another section use C<$section::name>
  100. or C<${section::name}>.
  101. By using C<$ENV::name>, the value of the specified environment
  102. variable will be substituted.
  103. Variables must be defined before their value is referenced, otherwise
  104. an error is flagged and the file will not load.
  105. This can be worked around by specifying a default value in the B<default>
  106. section before the variable is used.
  107. Any name/value settings in an B<ENV> section are available
  108. to the configuration file, but are not propagated to the environment.
  109. It is an error if the value ends up longer than 64k.
  110. It is possible to escape certain characters by using a single B<'> or
  111. double B<"> quote around the value, or using a backslash B<\> before the
  112. character,
  113. By making the last character of a line a B<\>
  114. a B<value> string can be spread across multiple lines. In addition
  115. the sequences B<\n>, B<\r>, B<\b> and B<\t> are recognized.
  116. The expansion and escape rules as described above that apply to B<value>
  117. also apply to the pathname of the B<.include> directive.
  118. =head1 OPENSSL LIBRARY CONFIGURATION
  119. The sections below use the informal term I<module> to refer to a part
  120. of the OpenSSL functionality. This is not the same as the formal term
  121. I<FIPS module>, for example.
  122. The OpenSSL configuration looks up the value of B<openssl_conf>
  123. in the default section and takes that as the name of a section that specifies
  124. how to configure any modules in the library. It is not an error to leave
  125. any module in its default configuration. An application can specify a
  126. different name by calling CONF_modules_load_file(), for example, directly.
  127. OpenSSL also looks up the value of B<config_diagnostics>.
  128. If this exists and has a nonzero numeric value, any error suppressing flags
  129. passed to CONF_modules_load() will be ignored.
  130. This is useful for diagnosing misconfigurations and should not be used in
  131. production.
  132. # This must be in the default section
  133. openssl_conf = openssl_init
  134. [openssl_init]
  135. oid_section = oids
  136. providers = providers
  137. alg_section = evp_properties
  138. ssl_conf = ssl_configuration
  139. engines = engines
  140. random = random
  141. [oids]
  142. ... new oids here ...
  143. [providers]
  144. ... provider stuff here ...
  145. [evp_properties]
  146. ... EVP properties here ...
  147. [ssl_configuration]
  148. ... SSL/TLS configuration properties here ...
  149. [engines]
  150. ... engine properties here ...
  151. [random]
  152. ... random properties here ...
  153. The semantics of each module are described below. The phrase "in the
  154. initialization section" refers to the section identified by the
  155. B<openssl_conf> or other name (given as B<openssl_init> in the
  156. example above). The examples below assume the configuration above
  157. is used to specify the individual sections.
  158. =head2 ASN.1 Object Identifier Configuration
  159. The name B<oid_section> in the initialization section names the section
  160. containing name/value pairs of OID's.
  161. The name is the short name; the value is an optional long name followed
  162. by a comma, and the numeric value.
  163. While some OpenSSL commands have their own section for specifying OID's,
  164. this section makes them available to all commands and applications.
  165. [oids]
  166. shortName = a very long OID name, 1.2.3.4
  167. newoid1 = 1.2.3.4.1
  168. some_other_oid = 1.2.3.5
  169. If a full configuration with the above fragment is in the file
  170. F<example.cnf>, then the following command line:
  171. OPENSSL_CONF=example.cnf openssl asn1parse -genstr OID:1.2.3.4.1
  172. will output:
  173. 0:d=0 hl=2 l= 4 prim: OBJECT :newoid1
  174. showing that the OID "newoid1" has been added as "1.2.3.4.1".
  175. =head2 Provider Configuration
  176. The name B<providers> in the initialization section names the section
  177. containing cryptographic provider configuration. The name/value assignments
  178. in this section each name a provider, and point to the configuration section
  179. for that provider. The provider-specific section is used to specify how
  180. to load the module, activate it, and set other parameters.
  181. Within a provider section, the following names have meaning:
  182. =over 4
  183. =item B<identity>
  184. This is used to specify an alternate name, overriding the default name
  185. specified in the list of providers. For example:
  186. [providers]
  187. foo = foo_provider
  188. [foo_provider]
  189. identity = my_fips_module
  190. =item B<module>
  191. Specifies the pathname of the module (typically a shared library) to load.
  192. =item B<activate>
  193. If present, the module is activated. The value assigned to this name is not
  194. significant.
  195. =back
  196. All parameters in the section as well as sub-sections are made
  197. available to the provider.
  198. =head2 EVP Configuration
  199. The name B<alg_section> in the initialization section names the section
  200. containing algorithmic properties when using the B<EVP> API.
  201. Within the algorithm properties section, the following names have meaning:
  202. =over 4
  203. =item B<default_properties>
  204. The value may be anything that is acceptable as a property query
  205. string for EVP_set_default_properties().
  206. =item B<fips_mode> (deprecated)
  207. The value is a boolean that can be B<yes> or B<no>. If the value is
  208. B<yes>, this is exactly equivalent to:
  209. default_properties = fips=yes
  210. If the value is B<no>, nothing happens. Using this name is deprecated, and
  211. if used, it must be the only name in the section.
  212. =back
  213. =head2 SSL Configuration
  214. The name B<ssl_conf> in the initialization section names the section
  215. containing the list of SSL/TLS configurations.
  216. As with the providers, each name in this section identifies a
  217. section with the configuration for that name. For example:
  218. [ssl_configuration]
  219. server = server_tls_config
  220. client = client_tls_config
  221. system_default = tls_system_default
  222. [server_tls_config]
  223. ... configuration for SSL/TLS servers ...
  224. [client_tls_config]
  225. ... configuration for SSL/TLS clients ...
  226. The configuration name B<system_default> has a special meaning. If it
  227. exists, it is applied whenever an B<SSL_CTX> object is created. For example,
  228. to impose system-wide minimum TLS and DTLS protocol versions:
  229. [tls_system_default]
  230. MinProtocol = TLSv1.2
  231. MinProtocol = DTLSv1.2
  232. The minimum TLS protocol is applied to B<SSL_CTX> objects that are TLS-based,
  233. and the minimum DTLS protocol to those are DTLS-based.
  234. The same applies also to maximum versions set with B<MaxProtocol>.
  235. Each configuration section consists of name/value pairs that are parsed
  236. by B<SSL_CONF_cmd(3)>, which will be called by SSL_CTX_config() or
  237. SSL_config(), appropriately. Note that any characters before an initial
  238. dot in the configuration section are ignored, so that the same command can
  239. be used multiple times. This probably is most useful for loading different
  240. key types, as shown here:
  241. [server_tls_config]
  242. RSA.Certificate = server-rsa.pem
  243. ECDSA.Certificate = server-ecdsa.pem
  244. =head2 Engine Configuration
  245. The name B<engines> in the initialization section names the section
  246. containing the list of ENGINE configurations.
  247. As with the providers, each name in this section identifies an engine
  248. with the configuration for that engine.
  249. The engine-specific section is used to specify how to load the engine,
  250. activate it, and set other parameters.
  251. Within an engine section, the following names have meaning:
  252. =over 4
  253. =item B<engine_id>
  254. This is used to specify an alternate name, overriding the default name
  255. specified in the list of engines. If present, it must be first.
  256. For example:
  257. [engines]
  258. foo = foo_engine
  259. [foo_engine]
  260. engine_id = myfoo
  261. =item B<dynamic_path>
  262. This loads and adds an ENGINE from the given path. It is equivalent to
  263. sending the ctrls B<SO_PATH> with the path argument followed by B<LIST_ADD>
  264. with value B<2> and B<LOAD> to the dynamic ENGINE. If this is not the
  265. required behaviour then alternative ctrls can be sent directly to the
  266. dynamic ENGINE using ctrl commands.
  267. =item B<init>
  268. This specifies whether to initialize the ENGINE. If the value is B<0> the
  269. ENGINE will not be initialized, if the value is B<1> an attempt is made
  270. to initialize
  271. the ENGINE immediately. If the B<init> command is not present then an
  272. attempt will be made to initialize the ENGINE after all commands in its
  273. section have been processed.
  274. =item B<default_algorithms>
  275. This sets the default algorithms an ENGINE will supply using the function
  276. ENGINE_set_default_string().
  277. =back
  278. All other names are taken to be the name of a ctrl command that is
  279. sent to the ENGINE, and the value is the argument passed with the command.
  280. The special value B<EMPTY> means no value is sent with the command.
  281. For example:
  282. [engines]
  283. foo = foo_engine
  284. [foo_engine]
  285. dynamic_path = /some/path/fooengine.so
  286. some_ctrl = some_value
  287. default_algorithms = ALL
  288. other_ctrl = EMPTY
  289. =head2 Random Configuration
  290. The name B<random> in the initialization section names the section
  291. containing the random number generater settings.
  292. Within the random section, the following names have meaning:
  293. =over 4
  294. =item B<random>
  295. This is used to specify the random bit generator.
  296. For example:
  297. [random]
  298. random = CTR-DRBG
  299. The available random bit generators are:
  300. =over 4
  301. =item B<CTR-DRBG>
  302. =item B<HASH-DRBG>
  303. =item B<HMAC-DRBG>
  304. =back
  305. =item B<cipher>
  306. This specifies what cipher a B<CTR-DRBG> random bit generator will use.
  307. Other random bit generators ignore this name.
  308. The default value is B<AES-256-CTR>.
  309. =item B<digest>
  310. This specifies what digest the B<HASH-DRBG> or B<HMAC-DRBG> random bit
  311. generators will use. Other random bit generators ignore this name.
  312. =item B<properties>
  313. This sets the property query used when fetching the random bit generator and
  314. any underlying algorithms.
  315. =item B<seed>
  316. This sets the randomness source that should be used. By default B<SEED-SRC>
  317. will be used outside of the FIPS provider. The FIPS provider uses call backs
  318. to access the same randomness sources from outside the validated boundary.
  319. =item B<seed_properties>
  320. This sets the property query used when fetching the randomness source.
  321. =back
  322. =head1 EXAMPLES
  323. This example shows how to use quoting and escaping.
  324. # This is the default section.
  325. HOME = /temp
  326. configdir = $ENV::HOME/config
  327. [ section_one ]
  328. # Quotes permit leading and trailing whitespace
  329. any = " any variable name "
  330. other = A string that can \
  331. cover several lines \
  332. by including \\ characters
  333. message = Hello World\n
  334. [ section_two ]
  335. greeting = $section_one::message
  336. This example shows how to expand environment variables safely.
  337. In this example, the variable B<tempfile> is intended to refer
  338. to a temporary file, and the environment variable B<TEMP> or
  339. B<TMP>, if present, specify the directory where the file
  340. should be put.
  341. Since the default section is checked if a variable does not
  342. exist, it is possible to set B<TMP> to default to F</tmp>, and
  343. B<TEMP> to default to B<TMP>.
  344. # These two lines must be in the default section.
  345. TMP = /tmp
  346. TEMP = $ENV::TMP
  347. # This can be used anywhere
  348. tmpfile = ${ENV::TEMP}/tmp.filename
  349. This example shows how to enforce FIPS mode for the application
  350. F<sample>.
  351. sample = fips_config
  352. [fips_config]
  353. alg_section = evp_properties
  354. [evp_properties]
  355. default_properties = "fips=yes"
  356. =head1 ENVIRONMENT
  357. =over 4
  358. =item B<OPENSSL_CONF>
  359. The path to the config file, or the empty string for none.
  360. Ignored in set-user-ID and set-group-ID programs.
  361. =item B<OPENSSL_ENGINES>
  362. The path to the engines directory.
  363. Ignored in set-user-ID and set-group-ID programs.
  364. =item B<OPENSSL_MODULES>
  365. The path to the directory with OpenSSL modules, such as providers.
  366. Ignored in set-user-ID and set-group-ID programs.
  367. =item B<OPENSSL_CONF_INCLUDE>
  368. The optional path to prepend to all B<.include> paths.
  369. =back
  370. =head1 BUGS
  371. There is no way to include characters using the octal B<\nnn> form. Strings
  372. are all null terminated so nulls cannot form part of the value.
  373. The escaping isn't quite right: if you want to use sequences like B<\n>
  374. you can't use any quote escaping on the same line.
  375. The limit that only one directory can be opened and read at a time
  376. can be considered a bug and should be fixed.
  377. =head1 HISTORY
  378. An undocumented API, NCONF_WIN32(), used a slightly different set
  379. of parsing rules there were intended to be tailored to
  380. the Microsoft Windows platform.
  381. Specifically, the backslash character was not an escape character and
  382. could be used in pathnames, only the double-quote character was recognized,
  383. and comments began with a semi-colon.
  384. This function was deprecated in OpenSSL 3.0; applications with
  385. configuration files using that syntax will have to be modified.
  386. =head1 SEE ALSO
  387. L<openssl-x509(1)>, L<openssl-req(1)>, L<openssl-ca(1)>,
  388. L<openssl-fipsinstall(1)>,
  389. L<ASN1_generate_nconf(3)>,
  390. L<EVP_set_default_properties(3)>,
  391. L<CONF_modules_load(3)>,
  392. L<CONF_modules_load_file(3)>,
  393. L<fips_config(5)>, and
  394. L<x509v3_config(5)>.
  395. =head1 COPYRIGHT
  396. Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
  397. Licensed under the Apache License 2.0 (the "License"). You may not use
  398. this file except in compliance with the License. You can obtain a copy
  399. in the file LICENSE in the source distribution or at
  400. L<https://www.openssl.org/source/license.html>.
  401. =cut