config.pod 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  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 and set to one of the values yes, on, true or 1, then the associated
  198. provider will be activated. Conversely, setting this value to no, off, false, or
  199. 0 will prevent the provider from being activated. Settings can be given in lower
  200. or uppercase. Setting activate to any other setting, or omitting a setting
  201. value will result in an error.
  202. = item B<soft_load>
  203. If enabled, informs the library to clear the error stack on failure to activate
  204. requested provider. A value of 1, yes, true or on (in lower or uppercase) will
  205. activate this setting, while a value of 0, no, false, of off (again in lower or
  206. uppercase) will disable this setting. Any other value will produce an error.
  207. Note this setting defaults to off if not provided
  208. =back
  209. All parameters in the section as well as sub-sections are made
  210. available to the provider.
  211. =head3 Default provider and its activation
  212. If no providers are activated explicitly, the default one is activated implicitly.
  213. See L<OSSL_PROVIDER-default(7)> for more details.
  214. If you add a section explicitly activating any other provider(s),
  215. you most probably need to explicitly activate the default provider,
  216. otherwise it becomes unavailable in openssl. It may make the system remotely unavailable.
  217. =head2 EVP Configuration
  218. The name B<alg_section> in the initialization section names the section
  219. containing algorithmic properties when using the B<EVP> API.
  220. Within the algorithm properties section, the following names have meaning:
  221. =over 4
  222. =item B<default_properties>
  223. The value may be anything that is acceptable as a property query
  224. string for EVP_set_default_properties().
  225. =item B<fips_mode> (deprecated)
  226. The value is a boolean that can be B<yes> or B<no>. If the value is
  227. B<yes>, this is exactly equivalent to:
  228. default_properties = fips=yes
  229. If the value is B<no>, nothing happens. Using this name is deprecated, and
  230. if used, it must be the only name in the section.
  231. =back
  232. =head2 SSL Configuration
  233. The name B<ssl_conf> in the initialization section names the section
  234. containing the list of SSL/TLS configurations.
  235. As with the providers, each name in this section identifies a
  236. section with the configuration for that name. For example:
  237. [ssl_configuration]
  238. server = server_tls_config
  239. client = client_tls_config
  240. system_default = tls_system_default
  241. [server_tls_config]
  242. ... configuration for SSL/TLS servers ...
  243. [client_tls_config]
  244. ... configuration for SSL/TLS clients ...
  245. The configuration name B<system_default> has a special meaning. If it
  246. exists, it is applied whenever an B<SSL_CTX> object is created. For example,
  247. to impose system-wide minimum TLS and DTLS protocol versions:
  248. [tls_system_default]
  249. MinProtocol = TLSv1.2
  250. MinProtocol = DTLSv1.2
  251. The minimum TLS protocol is applied to B<SSL_CTX> objects that are TLS-based,
  252. and the minimum DTLS protocol to those are DTLS-based.
  253. The same applies also to maximum versions set with B<MaxProtocol>.
  254. Each configuration section consists of name/value pairs that are parsed
  255. by B<SSL_CONF_cmd(3)>, which will be called by SSL_CTX_config() or
  256. SSL_config(), appropriately. Note that any characters before an initial
  257. dot in the configuration section are ignored, so that the same command can
  258. be used multiple times. This probably is most useful for loading different
  259. key types, as shown here:
  260. [server_tls_config]
  261. RSA.Certificate = server-rsa.pem
  262. ECDSA.Certificate = server-ecdsa.pem
  263. =head2 Engine Configuration
  264. The name B<engines> in the initialization section names the section
  265. containing the list of ENGINE configurations.
  266. As with the providers, each name in this section identifies an engine
  267. with the configuration for that engine.
  268. The engine-specific section is used to specify how to load the engine,
  269. activate it, and set other parameters.
  270. Within an engine section, the following names have meaning:
  271. =over 4
  272. =item B<engine_id>
  273. This is used to specify an alternate name, overriding the default name
  274. specified in the list of engines. If present, it must be first.
  275. For example:
  276. [engines]
  277. foo = foo_engine
  278. [foo_engine]
  279. engine_id = myfoo
  280. =item B<dynamic_path>
  281. This loads and adds an ENGINE from the given path. It is equivalent to
  282. sending the ctrls B<SO_PATH> with the path argument followed by B<LIST_ADD>
  283. with value B<2> and B<LOAD> to the dynamic ENGINE. If this is not the
  284. required behaviour then alternative ctrls can be sent directly to the
  285. dynamic ENGINE using ctrl commands.
  286. =item B<init>
  287. This specifies whether to initialize the ENGINE. If the value is B<0> the
  288. ENGINE will not be initialized, if the value is B<1> an attempt is made
  289. to initialize
  290. the ENGINE immediately. If the B<init> command is not present then an
  291. attempt will be made to initialize the ENGINE after all commands in its
  292. section have been processed.
  293. =item B<default_algorithms>
  294. This sets the default algorithms an ENGINE will supply using the function
  295. ENGINE_set_default_string().
  296. =back
  297. All other names are taken to be the name of a ctrl command that is
  298. sent to the ENGINE, and the value is the argument passed with the command.
  299. The special value B<EMPTY> means no value is sent with the command.
  300. For example:
  301. [engines]
  302. foo = foo_engine
  303. [foo_engine]
  304. dynamic_path = /some/path/fooengine.so
  305. some_ctrl = some_value
  306. default_algorithms = ALL
  307. other_ctrl = EMPTY
  308. =head2 Random Configuration
  309. The name B<random> in the initialization section names the section
  310. containing the random number generator settings.
  311. Within the random section, the following names have meaning:
  312. =over 4
  313. =item B<random>
  314. This is used to specify the random bit generator.
  315. For example:
  316. [random]
  317. random = CTR-DRBG
  318. The available random bit generators are:
  319. =over 4
  320. =item B<CTR-DRBG>
  321. =item B<HASH-DRBG>
  322. =item B<HMAC-DRBG>
  323. =back
  324. =item B<cipher>
  325. This specifies what cipher a B<CTR-DRBG> random bit generator will use.
  326. Other random bit generators ignore this name.
  327. The default value is B<AES-256-CTR>.
  328. =item B<digest>
  329. This specifies what digest the B<HASH-DRBG> or B<HMAC-DRBG> random bit
  330. generators will use. Other random bit generators ignore this name.
  331. =item B<properties>
  332. This sets the property query used when fetching the random bit generator and
  333. any underlying algorithms.
  334. =item B<seed>
  335. This sets the randomness source that should be used. By default B<SEED-SRC>
  336. will be used outside of the FIPS provider. The FIPS provider uses call backs
  337. to access the same randomness sources from outside the validated boundary.
  338. =item B<seed_properties>
  339. This sets the property query used when fetching the randomness source.
  340. =back
  341. =head1 EXAMPLES
  342. This example shows how to use quoting and escaping.
  343. # This is the default section.
  344. HOME = /temp
  345. configdir = $ENV::HOME/config
  346. [ section_one ]
  347. # Quotes permit leading and trailing whitespace
  348. any = " any variable name "
  349. other = A string that can \
  350. cover several lines \
  351. by including \\ characters
  352. message = Hello World\n
  353. [ section_two ]
  354. greeting = $section_one::message
  355. This example shows how to expand environment variables safely.
  356. In this example, the variable B<tempfile> is intended to refer
  357. to a temporary file, and the environment variable B<TEMP> or
  358. B<TMP>, if present, specify the directory where the file
  359. should be put.
  360. Since the default section is checked if a variable does not
  361. exist, it is possible to set B<TMP> to default to F</tmp>, and
  362. B<TEMP> to default to B<TMP>.
  363. # These two lines must be in the default section.
  364. TMP = /tmp
  365. TEMP = $ENV::TMP
  366. # This can be used anywhere
  367. tmpfile = ${ENV::TEMP}/tmp.filename
  368. This example shows how to enforce FIPS mode for the application
  369. F<sample>.
  370. sample = fips_config
  371. [fips_config]
  372. alg_section = evp_properties
  373. [evp_properties]
  374. default_properties = "fips=yes"
  375. =head1 ENVIRONMENT
  376. =over 4
  377. =item B<OPENSSL_CONF>
  378. The path to the config file, or the empty string for none.
  379. Ignored in set-user-ID and set-group-ID programs.
  380. =item B<OPENSSL_ENGINES>
  381. The path to the engines directory.
  382. Ignored in set-user-ID and set-group-ID programs.
  383. =item B<OPENSSL_MODULES>
  384. The path to the directory with OpenSSL modules, such as providers.
  385. Ignored in set-user-ID and set-group-ID programs.
  386. =item B<OPENSSL_CONF_INCLUDE>
  387. The optional path to prepend to all B<.include> paths.
  388. =back
  389. =head1 BUGS
  390. There is no way to include characters using the octal B<\nnn> form. Strings
  391. are all null terminated so nulls cannot form part of the value.
  392. The escaping isn't quite right: if you want to use sequences like B<\n>
  393. you can't use any quote escaping on the same line.
  394. The limit that only one directory can be opened and read at a time
  395. can be considered a bug and should be fixed.
  396. =head1 HISTORY
  397. An undocumented API, NCONF_WIN32(), used a slightly different set
  398. of parsing rules there were intended to be tailored to
  399. the Microsoft Windows platform.
  400. Specifically, the backslash character was not an escape character and
  401. could be used in pathnames, only the double-quote character was recognized,
  402. and comments began with a semi-colon.
  403. This function was deprecated in OpenSSL 3.0; applications with
  404. configuration files using that syntax will have to be modified.
  405. =head1 SEE ALSO
  406. L<openssl-x509(1)>, L<openssl-req(1)>, L<openssl-ca(1)>,
  407. L<openssl-fipsinstall(1)>,
  408. L<ASN1_generate_nconf(3)>,
  409. L<EVP_set_default_properties(3)>,
  410. L<CONF_modules_load(3)>,
  411. L<CONF_modules_load_file(3)>,
  412. L<fips_config(5)>, and
  413. L<x509v3_config(5)>.
  414. =head1 COPYRIGHT
  415. Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved.
  416. Licensed under the Apache License 2.0 (the "License"). You may not use
  417. this file except in compliance with the License. You can obtain a copy
  418. in the file LICENSE in the source distribution or at
  419. L<https://www.openssl.org/source/license.html>.
  420. =cut