config.pod 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  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 and
  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 but its use in
  131. production requires additional consideration. With this option enabled,
  132. a configuration error will completely prevent access to a service.
  133. Without this option and in the presence of a configuration error, access
  134. will be allowed but the desired configuration will B<not> be used.
  135. # These must be in the default section
  136. config_diagnostics = 1
  137. openssl_conf = openssl_init
  138. [openssl_init]
  139. oid_section = oids
  140. providers = providers
  141. alg_section = evp_properties
  142. ssl_conf = ssl_configuration
  143. engines = engines
  144. random = random
  145. [oids]
  146. ... new oids here ...
  147. [providers]
  148. ... provider stuff here ...
  149. [evp_properties]
  150. ... EVP properties here ...
  151. [ssl_configuration]
  152. ... SSL/TLS configuration properties here ...
  153. [engines]
  154. ... engine properties here ...
  155. [random]
  156. ... random properties here ...
  157. The semantics of each module are described below. The phrase "in the
  158. initialization section" refers to the section identified by the
  159. B<openssl_conf> or other name (given as B<openssl_init> in the
  160. example above). The examples below assume the configuration above
  161. is used to specify the individual sections.
  162. =head2 ASN.1 Object Identifier Configuration
  163. The name B<oid_section> in the initialization section names the section
  164. containing name/value pairs of OID's.
  165. The name is the short name; the value is an optional long name followed
  166. by a comma, and the numeric value.
  167. While some OpenSSL commands have their own section for specifying OID's,
  168. this section makes them available to all commands and applications.
  169. [oids]
  170. shortName = a very long OID name, 1.2.3.4
  171. newoid1 = 1.2.3.4.1
  172. some_other_oid = 1.2.3.5
  173. If a full configuration with the above fragment is in the file
  174. F<example.cnf>, then the following command line:
  175. OPENSSL_CONF=example.cnf openssl asn1parse -genstr OID:1.2.3.4.1
  176. will output:
  177. 0:d=0 hl=2 l= 4 prim: OBJECT :newoid1
  178. showing that the OID "newoid1" has been added as "1.2.3.4.1".
  179. =head2 Provider Configuration
  180. The name B<providers> in the initialization section names the section
  181. containing cryptographic provider configuration. The name/value assignments
  182. in this section each name a provider, and point to the configuration section
  183. for that provider. The provider-specific section is used to specify how
  184. to load the module, activate it, and set other parameters.
  185. Within a provider section, the following names have meaning:
  186. =over 4
  187. =item B<identity>
  188. This is used to specify an alternate name, overriding the default name
  189. specified in the list of providers. For example:
  190. [providers]
  191. foo = foo_provider
  192. [foo_provider]
  193. identity = my_fips_module
  194. =item B<module>
  195. Specifies the pathname of the module (typically a shared library) to load.
  196. =item B<activate>
  197. If present, the module is activated. The value assigned to this name is not
  198. significant.
  199. =back
  200. All parameters in the section as well as sub-sections are made
  201. available to the provider.
  202. =head3 Default provider and its activation
  203. If no providers are activated explicitly, the default one is activated implicitly.
  204. See L<OSSL_PROVIDER-default(7)> for more details.
  205. If you add a section explicitly activating any other provider(s),
  206. you most probably need to explicitly activate the default provider,
  207. otherwise it becomes unavailable in openssl. It may make the system remotely unavailable.
  208. =head2 EVP Configuration
  209. The name B<alg_section> in the initialization section names the section
  210. containing algorithmic properties when using the B<EVP> API.
  211. Within the algorithm properties section, the following names have meaning:
  212. =over 4
  213. =item B<default_properties>
  214. The value may be anything that is acceptable as a property query
  215. string for EVP_set_default_properties().
  216. =item B<fips_mode> (deprecated)
  217. The value is a boolean that can be B<yes> or B<no>. If the value is
  218. B<yes>, this is exactly equivalent to:
  219. default_properties = fips=yes
  220. If the value is B<no>, nothing happens. Using this name is deprecated, and
  221. if used, it must be the only name in the section.
  222. =back
  223. =head2 SSL Configuration
  224. The name B<ssl_conf> in the initialization section names the section
  225. containing the list of SSL/TLS configurations.
  226. As with the providers, each name in this section identifies a
  227. section with the configuration for that name. For example:
  228. [ssl_configuration]
  229. server = server_tls_config
  230. client = client_tls_config
  231. system_default = tls_system_default
  232. [server_tls_config]
  233. ... configuration for SSL/TLS servers ...
  234. [client_tls_config]
  235. ... configuration for SSL/TLS clients ...
  236. The configuration name B<system_default> has a special meaning. If it
  237. exists, it is applied whenever an B<SSL_CTX> object is created. For example,
  238. to impose system-wide minimum TLS and DTLS protocol versions:
  239. [tls_system_default]
  240. MinProtocol = TLSv1.2
  241. MinProtocol = DTLSv1.2
  242. The minimum TLS protocol is applied to B<SSL_CTX> objects that are TLS-based,
  243. and the minimum DTLS protocol to those are DTLS-based.
  244. The same applies also to maximum versions set with B<MaxProtocol>.
  245. Each configuration section consists of name/value pairs that are parsed
  246. by B<SSL_CONF_cmd(3)>, which will be called by SSL_CTX_config() or
  247. SSL_config(), appropriately. Note that any characters before an initial
  248. dot in the configuration section are ignored, so that the same command can
  249. be used multiple times. This probably is most useful for loading different
  250. key types, as shown here:
  251. [server_tls_config]
  252. RSA.Certificate = server-rsa.pem
  253. ECDSA.Certificate = server-ecdsa.pem
  254. =head2 Engine Configuration
  255. The name B<engines> in the initialization section names the section
  256. containing the list of ENGINE configurations.
  257. As with the providers, each name in this section identifies an engine
  258. with the configuration for that engine.
  259. The engine-specific section is used to specify how to load the engine,
  260. activate it, and set other parameters.
  261. Within an engine section, the following names have meaning:
  262. =over 4
  263. =item B<engine_id>
  264. This is used to specify an alternate name, overriding the default name
  265. specified in the list of engines. If present, it must be first.
  266. For example:
  267. [engines]
  268. foo = foo_engine
  269. [foo_engine]
  270. engine_id = myfoo
  271. =item B<dynamic_path>
  272. This loads and adds an ENGINE from the given path. It is equivalent to
  273. sending the ctrls B<SO_PATH> with the path argument followed by B<LIST_ADD>
  274. with value B<2> and B<LOAD> to the dynamic ENGINE. If this is not the
  275. required behaviour then alternative ctrls can be sent directly to the
  276. dynamic ENGINE using ctrl commands.
  277. =item B<init>
  278. This specifies whether to initialize the ENGINE. If the value is B<0> the
  279. ENGINE will not be initialized, if the value is B<1> an attempt is made
  280. to initialize
  281. the ENGINE immediately. If the B<init> command is not present then an
  282. attempt will be made to initialize the ENGINE after all commands in its
  283. section have been processed.
  284. =item B<default_algorithms>
  285. This sets the default algorithms an ENGINE will supply using the function
  286. ENGINE_set_default_string().
  287. =back
  288. All other names are taken to be the name of a ctrl command that is
  289. sent to the ENGINE, and the value is the argument passed with the command.
  290. The special value B<EMPTY> means no value is sent with the command.
  291. For example:
  292. [engines]
  293. foo = foo_engine
  294. [foo_engine]
  295. dynamic_path = /some/path/fooengine.so
  296. some_ctrl = some_value
  297. default_algorithms = ALL
  298. other_ctrl = EMPTY
  299. =head2 Random Configuration
  300. The name B<random> in the initialization section names the section
  301. containing the random number generator settings.
  302. Within the random section, the following names have meaning:
  303. =over 4
  304. =item B<random>
  305. This is used to specify the random bit generator.
  306. For example:
  307. [random]
  308. random = CTR-DRBG
  309. The available random bit generators are:
  310. =over 4
  311. =item B<CTR-DRBG>
  312. =item B<HASH-DRBG>
  313. =item B<HMAC-DRBG>
  314. =back
  315. =item B<cipher>
  316. This specifies what cipher a B<CTR-DRBG> random bit generator will use.
  317. Other random bit generators ignore this name.
  318. The default value is B<AES-256-CTR>.
  319. =item B<digest>
  320. This specifies what digest the B<HASH-DRBG> or B<HMAC-DRBG> random bit
  321. generators will use. Other random bit generators ignore this name.
  322. =item B<properties>
  323. This sets the property query used when fetching the random bit generator and
  324. any underlying algorithms.
  325. =item B<seed>
  326. This sets the randomness source that should be used. By default B<SEED-SRC>
  327. will be used outside of the FIPS provider. The FIPS provider uses call backs
  328. to access the same randomness sources from outside the validated boundary.
  329. =item B<seed_properties>
  330. This sets the property query used when fetching the randomness source.
  331. =back
  332. =head1 EXAMPLES
  333. This example shows how to use quoting and escaping.
  334. # This is the default section.
  335. HOME = /temp
  336. configdir = $ENV::HOME/config
  337. [ section_one ]
  338. # Quotes permit leading and trailing whitespace
  339. any = " any variable name "
  340. other = A string that can \
  341. cover several lines \
  342. by including \\ characters
  343. message = Hello World\n
  344. [ section_two ]
  345. greeting = $section_one::message
  346. This example shows how to expand environment variables safely.
  347. In this example, the variable B<tempfile> is intended to refer
  348. to a temporary file, and the environment variable B<TEMP> or
  349. B<TMP>, if present, specify the directory where the file
  350. should be put.
  351. Since the default section is checked if a variable does not
  352. exist, it is possible to set B<TMP> to default to F</tmp>, and
  353. B<TEMP> to default to B<TMP>.
  354. # These two lines must be in the default section.
  355. TMP = /tmp
  356. TEMP = $ENV::TMP
  357. # This can be used anywhere
  358. tmpfile = ${ENV::TEMP}/tmp.filename
  359. This example shows how to enforce FIPS mode for the application
  360. F<sample>.
  361. sample = fips_config
  362. [fips_config]
  363. alg_section = evp_properties
  364. [evp_properties]
  365. default_properties = "fips=yes"
  366. =head1 ENVIRONMENT
  367. =over 4
  368. =item B<OPENSSL_CONF>
  369. The path to the config file, or the empty string for none.
  370. Ignored in set-user-ID and set-group-ID programs.
  371. =item B<OPENSSL_ENGINES>
  372. The path to the engines directory.
  373. Ignored in set-user-ID and set-group-ID programs.
  374. =item B<OPENSSL_MODULES>
  375. The path to the directory with OpenSSL modules, such as providers.
  376. Ignored in set-user-ID and set-group-ID programs.
  377. =item B<OPENSSL_CONF_INCLUDE>
  378. The optional path to prepend to all B<.include> paths.
  379. =back
  380. =head1 BUGS
  381. There is no way to include characters using the octal B<\nnn> form. Strings
  382. are all null terminated so nulls cannot form part of the value.
  383. The escaping isn't quite right: if you want to use sequences like B<\n>
  384. you can't use any quote escaping on the same line.
  385. The limit that only one directory can be opened and read at a time
  386. can be considered a bug and should be fixed.
  387. =head1 HISTORY
  388. An undocumented API, NCONF_WIN32(), used a slightly different set
  389. of parsing rules there were intended to be tailored to
  390. the Microsoft Windows platform.
  391. Specifically, the backslash character was not an escape character and
  392. could be used in pathnames, only the double-quote character was recognized,
  393. and comments began with a semi-colon.
  394. This function was deprecated in OpenSSL 3.0; applications with
  395. configuration files using that syntax will have to be modified.
  396. =head1 SEE ALSO
  397. L<openssl-x509(1)>, L<openssl-req(1)>, L<openssl-ca(1)>,
  398. L<openssl-fipsinstall(1)>,
  399. L<ASN1_generate_nconf(3)>,
  400. L<EVP_set_default_properties(3)>,
  401. L<CONF_modules_load(3)>,
  402. L<CONF_modules_load_file(3)>,
  403. L<fips_config(5)>, and
  404. L<x509v3_config(5)>.
  405. =head1 COPYRIGHT
  406. Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved.
  407. Licensed under the Apache License 2.0 (the "License"). You may not use
  408. this file except in compliance with the License. You can obtain a copy
  409. in the file LICENSE in the source distribution or at
  410. L<https://www.openssl.org/source/license.html>.
  411. =cut