1*4724848cSchristos=pod 2*4724848cSchristos 3*4724848cSchristos=head1 NAME 4*4724848cSchristos 5*4724848cSchristosconfig - OpenSSL CONF library configuration files 6*4724848cSchristos 7*4724848cSchristos=head1 DESCRIPTION 8*4724848cSchristos 9*4724848cSchristosThe OpenSSL CONF library can be used to read configuration files. 10*4724848cSchristosIt is used for the OpenSSL master configuration file B<openssl.cnf> 11*4724848cSchristosand in a few other places like B<SPKAC> files and certificate extension 12*4724848cSchristosfiles for the B<x509> utility. OpenSSL applications can also use the 13*4724848cSchristosCONF library for their own purposes. 14*4724848cSchristos 15*4724848cSchristosA configuration file is divided into a number of sections. Each section 16*4724848cSchristosstarts with a line B<[ section_name ]> and ends when a new section is 17*4724848cSchristosstarted or end of file is reached. A section name can consist of 18*4724848cSchristosalphanumeric characters and underscores. 19*4724848cSchristos 20*4724848cSchristosThe first section of a configuration file is special and is referred 21*4724848cSchristosto as the B<default> section. This section is usually unnamed and spans from the 22*4724848cSchristosstart of file until the first named section. When a name is being looked up 23*4724848cSchristosit is first looked up in a named section (if any) and then the 24*4724848cSchristosdefault section. 25*4724848cSchristos 26*4724848cSchristosThe environment is mapped onto a section called B<ENV>. 27*4724848cSchristos 28*4724848cSchristosComments can be included by preceding them with the B<#> character 29*4724848cSchristos 30*4724848cSchristosOther files can be included using the B<.include> directive followed 31*4724848cSchristosby a path. If the path points to a directory all files with 32*4724848cSchristosnames ending with B<.cnf> or B<.conf> are included from the directory. 33*4724848cSchristosRecursive inclusion of directories from files in such directory is not 34*4724848cSchristossupported. That means the files in the included directory can also contain 35*4724848cSchristosB<.include> directives but only inclusion of regular files is supported 36*4724848cSchristosthere. The inclusion of directories is not supported on systems without 37*4724848cSchristosPOSIX IO support. 38*4724848cSchristos 39*4724848cSchristosIt is strongly recommended to use absolute paths with the B<.include> 40*4724848cSchristosdirective. Relative paths are evaluated based on the application current 41*4724848cSchristosworking directory so unless the configuration file containing the 42*4724848cSchristosB<.include> directive is application specific the inclusion will not 43*4724848cSchristoswork as expected. 44*4724848cSchristos 45*4724848cSchristosThere can be optional B<=> character and whitespace characters between 46*4724848cSchristosB<.include> directive and the path which can be useful in cases the 47*4724848cSchristosconfiguration file needs to be loaded by old OpenSSL versions which do 48*4724848cSchristosnot support the B<.include> syntax. They would bail out with error 49*4724848cSchristosif the B<=> character is not present but with it they just ignore 50*4724848cSchristosthe include. 51*4724848cSchristos 52*4724848cSchristosEach section in a configuration file consists of a number of name and 53*4724848cSchristosvalue pairs of the form B<name=value> 54*4724848cSchristos 55*4724848cSchristosThe B<name> string can contain any alphanumeric characters as well as 56*4724848cSchristosa few punctuation symbols such as B<.> B<,> B<;> and B<_>. 57*4724848cSchristos 58*4724848cSchristosThe B<value> string consists of the string following the B<=> character 59*4724848cSchristosuntil end of line with any leading and trailing white space removed. 60*4724848cSchristos 61*4724848cSchristosThe value string undergoes variable expansion. This can be done by 62*4724848cSchristosincluding the form B<$var> or B<${var}>: this will substitute the value 63*4724848cSchristosof the named variable in the current section. It is also possible to 64*4724848cSchristossubstitute a value from another section using the syntax B<$section::name> 65*4724848cSchristosor B<${section::name}>. By using the form B<$ENV::name> environment 66*4724848cSchristosvariables can be substituted. It is also possible to assign values to 67*4724848cSchristosenvironment variables by using the name B<ENV::name>, this will work 68*4724848cSchristosif the program looks up environment variables using the B<CONF> library 69*4724848cSchristosinstead of calling getenv() directly. The value string must not exceed 64k in 70*4724848cSchristoslength after variable expansion. Otherwise an error will occur. 71*4724848cSchristos 72*4724848cSchristosIt is possible to escape certain characters by using any kind of quote 73*4724848cSchristosor the B<\> character. By making the last character of a line a B<\> 74*4724848cSchristosa B<value> string can be spread across multiple lines. In addition 75*4724848cSchristosthe sequences B<\n>, B<\r>, B<\b> and B<\t> are recognized. 76*4724848cSchristos 77*4724848cSchristosAll expansion and escape rules as described above that apply to B<value> 78*4724848cSchristosalso apply to the path of the B<.include> directive. 79*4724848cSchristos 80*4724848cSchristos=head1 OPENSSL LIBRARY CONFIGURATION 81*4724848cSchristos 82*4724848cSchristosApplications can automatically configure certain 83*4724848cSchristosaspects of OpenSSL using the master OpenSSL configuration file, or optionally 84*4724848cSchristosan alternative configuration file. The B<openssl> utility includes this 85*4724848cSchristosfunctionality: any sub command uses the master OpenSSL configuration file 86*4724848cSchristosunless an option is used in the sub command to use an alternative configuration 87*4724848cSchristosfile. 88*4724848cSchristos 89*4724848cSchristosTo enable library configuration the default section needs to contain an 90*4724848cSchristosappropriate line which points to the main configuration section. The default 91*4724848cSchristosname is B<openssl_conf> which is used by the B<openssl> utility. Other 92*4724848cSchristosapplications may use an alternative name such as B<myapplication_conf>. 93*4724848cSchristosAll library configuration lines appear in the default section at the start 94*4724848cSchristosof the configuration file. 95*4724848cSchristos 96*4724848cSchristosThe configuration section should consist of a set of name value pairs which 97*4724848cSchristoscontain specific module configuration information. The B<name> represents 98*4724848cSchristosthe name of the I<configuration module>. The meaning of the B<value> is 99*4724848cSchristosmodule specific: it may, for example, represent a further configuration 100*4724848cSchristossection containing configuration module specific information. E.g.: 101*4724848cSchristos 102*4724848cSchristos # This must be in the default section 103*4724848cSchristos openssl_conf = openssl_init 104*4724848cSchristos 105*4724848cSchristos [openssl_init] 106*4724848cSchristos 107*4724848cSchristos oid_section = new_oids 108*4724848cSchristos engines = engine_section 109*4724848cSchristos 110*4724848cSchristos [new_oids] 111*4724848cSchristos 112*4724848cSchristos ... new oids here ... 113*4724848cSchristos 114*4724848cSchristos [engine_section] 115*4724848cSchristos 116*4724848cSchristos ... engine stuff here ... 117*4724848cSchristos 118*4724848cSchristosThe features of each configuration module are described below. 119*4724848cSchristos 120*4724848cSchristos=head2 ASN1 Object Configuration Module 121*4724848cSchristos 122*4724848cSchristosThis module has the name B<oid_section>. The value of this variable points 123*4724848cSchristosto a section containing name value pairs of OIDs: the name is the OID short 124*4724848cSchristosand long name, the value is the numerical form of the OID. Although some of 125*4724848cSchristosthe B<openssl> utility sub commands already have their own ASN1 OBJECT section 126*4724848cSchristosfunctionality not all do. By using the ASN1 OBJECT configuration module 127*4724848cSchristosB<all> the B<openssl> utility sub commands can see the new objects as well 128*4724848cSchristosas any compliant applications. For example: 129*4724848cSchristos 130*4724848cSchristos [new_oids] 131*4724848cSchristos 132*4724848cSchristos some_new_oid = 1.2.3.4 133*4724848cSchristos some_other_oid = 1.2.3.5 134*4724848cSchristos 135*4724848cSchristosIt is also possible to set the value to the long name followed 136*4724848cSchristosby a comma and the numerical OID form. For example: 137*4724848cSchristos 138*4724848cSchristos shortName = some object long name, 1.2.3.4 139*4724848cSchristos 140*4724848cSchristos=head2 Engine Configuration Module 141*4724848cSchristos 142*4724848cSchristosThis ENGINE configuration module has the name B<engines>. The value of this 143*4724848cSchristosvariable points to a section containing further ENGINE configuration 144*4724848cSchristosinformation. 145*4724848cSchristos 146*4724848cSchristosThe section pointed to by B<engines> is a table of engine names (though see 147*4724848cSchristosB<engine_id> below) and further sections containing configuration information 148*4724848cSchristosspecific to each ENGINE. 149*4724848cSchristos 150*4724848cSchristosEach ENGINE specific section is used to set default algorithms, load 151*4724848cSchristosdynamic, perform initialization and send ctrls. The actual operation performed 152*4724848cSchristosdepends on the I<command> name which is the name of the name value pair. The 153*4724848cSchristoscurrently supported commands are listed below. 154*4724848cSchristos 155*4724848cSchristosFor example: 156*4724848cSchristos 157*4724848cSchristos [engine_section] 158*4724848cSchristos 159*4724848cSchristos # Configure ENGINE named "foo" 160*4724848cSchristos foo = foo_section 161*4724848cSchristos # Configure ENGINE named "bar" 162*4724848cSchristos bar = bar_section 163*4724848cSchristos 164*4724848cSchristos [foo_section] 165*4724848cSchristos ... foo ENGINE specific commands ... 166*4724848cSchristos 167*4724848cSchristos [bar_section] 168*4724848cSchristos ... "bar" ENGINE specific commands ... 169*4724848cSchristos 170*4724848cSchristosThe command B<engine_id> is used to give the ENGINE name. If used this 171*4724848cSchristoscommand must be first. For example: 172*4724848cSchristos 173*4724848cSchristos [engine_section] 174*4724848cSchristos # This would normally handle an ENGINE named "foo" 175*4724848cSchristos foo = foo_section 176*4724848cSchristos 177*4724848cSchristos [foo_section] 178*4724848cSchristos # Override default name and use "myfoo" instead. 179*4724848cSchristos engine_id = myfoo 180*4724848cSchristos 181*4724848cSchristosThe command B<dynamic_path> loads and adds an ENGINE from the given path. It 182*4724848cSchristosis equivalent to sending the ctrls B<SO_PATH> with the path argument followed 183*4724848cSchristosby B<LIST_ADD> with value 2 and B<LOAD> to the dynamic ENGINE. If this is 184*4724848cSchristosnot the required behaviour then alternative ctrls can be sent directly 185*4724848cSchristosto the dynamic ENGINE using ctrl commands. 186*4724848cSchristos 187*4724848cSchristosThe command B<init> determines whether to initialize the ENGINE. If the value 188*4724848cSchristosis B<0> the ENGINE will not be initialized, if B<1> and attempt it made to 189*4724848cSchristosinitialized the ENGINE immediately. If the B<init> command is not present 190*4724848cSchristosthen an attempt will be made to initialize the ENGINE after all commands in 191*4724848cSchristosits section have been processed. 192*4724848cSchristos 193*4724848cSchristosThe command B<default_algorithms> sets the default algorithms an ENGINE will 194*4724848cSchristossupply using the functions ENGINE_set_default_string(). 195*4724848cSchristos 196*4724848cSchristosIf the name matches none of the above command names it is assumed to be a 197*4724848cSchristosctrl command which is sent to the ENGINE. The value of the command is the 198*4724848cSchristosargument to the ctrl command. If the value is the string B<EMPTY> then no 199*4724848cSchristosvalue is sent to the command. 200*4724848cSchristos 201*4724848cSchristosFor example: 202*4724848cSchristos 203*4724848cSchristos 204*4724848cSchristos [engine_section] 205*4724848cSchristos 206*4724848cSchristos # Configure ENGINE named "foo" 207*4724848cSchristos foo = foo_section 208*4724848cSchristos 209*4724848cSchristos [foo_section] 210*4724848cSchristos # Load engine from DSO 211*4724848cSchristos dynamic_path = /some/path/fooengine.so 212*4724848cSchristos # A foo specific ctrl. 213*4724848cSchristos some_ctrl = some_value 214*4724848cSchristos # Another ctrl that doesn't take a value. 215*4724848cSchristos other_ctrl = EMPTY 216*4724848cSchristos # Supply all default algorithms 217*4724848cSchristos default_algorithms = ALL 218*4724848cSchristos 219*4724848cSchristos=head2 EVP Configuration Module 220*4724848cSchristos 221*4724848cSchristosThis modules has the name B<alg_section> which points to a section containing 222*4724848cSchristosalgorithm commands. 223*4724848cSchristos 224*4724848cSchristosCurrently the only algorithm command supported is B<fips_mode> whose 225*4724848cSchristosvalue can only be the boolean string B<off>. If B<fips_mode> is set to B<on>, 226*4724848cSchristosan error occurs as this library version is not FIPS capable. 227*4724848cSchristos 228*4724848cSchristos=head2 SSL Configuration Module 229*4724848cSchristos 230*4724848cSchristosThis module has the name B<ssl_conf> which points to a section containing 231*4724848cSchristosSSL configurations. 232*4724848cSchristos 233*4724848cSchristosEach line in the SSL configuration section contains the name of the 234*4724848cSchristosconfiguration and the section containing it. 235*4724848cSchristos 236*4724848cSchristosEach configuration section consists of command value pairs for B<SSL_CONF>. 237*4724848cSchristosEach pair will be passed to a B<SSL_CTX> or B<SSL> structure if it calls 238*4724848cSchristosSSL_CTX_config() or SSL_config() with the appropriate configuration name. 239*4724848cSchristos 240*4724848cSchristosNote: any characters before an initial dot in the configuration section are 241*4724848cSchristosignored so the same command can be used multiple times. 242*4724848cSchristos 243*4724848cSchristosFor example: 244*4724848cSchristos 245*4724848cSchristos ssl_conf = ssl_sect 246*4724848cSchristos 247*4724848cSchristos [ssl_sect] 248*4724848cSchristos 249*4724848cSchristos server = server_section 250*4724848cSchristos 251*4724848cSchristos [server_section] 252*4724848cSchristos 253*4724848cSchristos RSA.Certificate = server-rsa.pem 254*4724848cSchristos ECDSA.Certificate = server-ecdsa.pem 255*4724848cSchristos Ciphers = ALL:!RC4 256*4724848cSchristos 257*4724848cSchristosThe system default configuration with name B<system_default> if present will 258*4724848cSchristosbe applied during any creation of the B<SSL_CTX> structure. 259*4724848cSchristos 260*4724848cSchristosExample of a configuration with the system default: 261*4724848cSchristos 262*4724848cSchristos ssl_conf = ssl_sect 263*4724848cSchristos 264*4724848cSchristos [ssl_sect] 265*4724848cSchristos system_default = system_default_sect 266*4724848cSchristos 267*4724848cSchristos [system_default_sect] 268*4724848cSchristos MinProtocol = TLSv1.2 269*4724848cSchristos MinProtocol = DTLSv1.2 270*4724848cSchristos 271*4724848cSchristos=head1 NOTES 272*4724848cSchristos 273*4724848cSchristosIf a configuration file attempts to expand a variable that doesn't exist 274*4724848cSchristosthen an error is flagged and the file will not load. This can happen 275*4724848cSchristosif an attempt is made to expand an environment variable that doesn't 276*4724848cSchristosexist. For example in a previous version of OpenSSL the default OpenSSL 277*4724848cSchristosmaster configuration file used the value of B<HOME> which may not be 278*4724848cSchristosdefined on non Unix systems and would cause an error. 279*4724848cSchristos 280*4724848cSchristosThis can be worked around by including a B<default> section to provide 281*4724848cSchristosa default value: then if the environment lookup fails the default value 282*4724848cSchristoswill be used instead. For this to work properly the default value must 283*4724848cSchristosbe defined earlier in the configuration file than the expansion. See 284*4724848cSchristosthe B<EXAMPLES> section for an example of how to do this. 285*4724848cSchristos 286*4724848cSchristosIf the same variable exists in the same section then all but the last 287*4724848cSchristosvalue will be silently ignored. In certain circumstances such as with 288*4724848cSchristosDNs the same field may occur multiple times. This is usually worked 289*4724848cSchristosaround by ignoring any characters before an initial B<.> e.g. 290*4724848cSchristos 291*4724848cSchristos 1.OU="My first OU" 292*4724848cSchristos 2.OU="My Second OU" 293*4724848cSchristos 294*4724848cSchristos=head1 EXAMPLES 295*4724848cSchristos 296*4724848cSchristosHere is a sample configuration file using some of the features 297*4724848cSchristosmentioned above. 298*4724848cSchristos 299*4724848cSchristos # This is the default section. 300*4724848cSchristos 301*4724848cSchristos HOME=/temp 302*4724848cSchristos RANDFILE= ${ENV::HOME}/.rnd 303*4724848cSchristos configdir=$ENV::HOME/config 304*4724848cSchristos 305*4724848cSchristos [ section_one ] 306*4724848cSchristos 307*4724848cSchristos # We are now in section one. 308*4724848cSchristos 309*4724848cSchristos # Quotes permit leading and trailing whitespace 310*4724848cSchristos any = " any variable name " 311*4724848cSchristos 312*4724848cSchristos other = A string that can \ 313*4724848cSchristos cover several lines \ 314*4724848cSchristos by including \\ characters 315*4724848cSchristos 316*4724848cSchristos message = Hello World\n 317*4724848cSchristos 318*4724848cSchristos [ section_two ] 319*4724848cSchristos 320*4724848cSchristos greeting = $section_one::message 321*4724848cSchristos 322*4724848cSchristosThis next example shows how to expand environment variables safely. 323*4724848cSchristos 324*4724848cSchristosSuppose you want a variable called B<tmpfile> to refer to a 325*4724848cSchristostemporary filename. The directory it is placed in can determined by 326*4724848cSchristosthe B<TEMP> or B<TMP> environment variables but they may not be 327*4724848cSchristosset to any value at all. If you just include the environment variable 328*4724848cSchristosnames and the variable doesn't exist then this will cause an error when 329*4724848cSchristosan attempt is made to load the configuration file. By making use of the 330*4724848cSchristosdefault section both values can be looked up with B<TEMP> taking 331*4724848cSchristospriority and B</tmp> used if neither is defined: 332*4724848cSchristos 333*4724848cSchristos TMP=/tmp 334*4724848cSchristos # The above value is used if TMP isn't in the environment 335*4724848cSchristos TEMP=$ENV::TMP 336*4724848cSchristos # The above value is used if TEMP isn't in the environment 337*4724848cSchristos tmpfile=${ENV::TEMP}/tmp.filename 338*4724848cSchristos 339*4724848cSchristosSimple OpenSSL library configuration example to enter FIPS mode: 340*4724848cSchristos 341*4724848cSchristos # Default appname: should match "appname" parameter (if any) 342*4724848cSchristos # supplied to CONF_modules_load_file et al. 343*4724848cSchristos openssl_conf = openssl_conf_section 344*4724848cSchristos 345*4724848cSchristos [openssl_conf_section] 346*4724848cSchristos # Configuration module list 347*4724848cSchristos alg_section = evp_sect 348*4724848cSchristos 349*4724848cSchristos [evp_sect] 350*4724848cSchristos # Set to "yes" to enter FIPS mode if supported 351*4724848cSchristos fips_mode = yes 352*4724848cSchristos 353*4724848cSchristosNote: in the above example you will get an error in non FIPS capable versions 354*4724848cSchristosof OpenSSL. 355*4724848cSchristos 356*4724848cSchristosSimple OpenSSL library configuration to make TLS 1.2 and DTLS 1.2 the 357*4724848cSchristossystem-default minimum TLS and DTLS versions, respectively: 358*4724848cSchristos 359*4724848cSchristos # Toplevel section for openssl (including libssl) 360*4724848cSchristos openssl_conf = default_conf_section 361*4724848cSchristos 362*4724848cSchristos [default_conf_section] 363*4724848cSchristos # We only specify configuration for the "ssl module" 364*4724848cSchristos ssl_conf = ssl_section 365*4724848cSchristos 366*4724848cSchristos [ssl_section] 367*4724848cSchristos system_default = system_default_section 368*4724848cSchristos 369*4724848cSchristos [system_default_section] 370*4724848cSchristos MinProtocol = TLSv1.2 371*4724848cSchristos MinProtocol = DTLSv1.2 372*4724848cSchristos 373*4724848cSchristosThe minimum TLS protocol is applied to B<SSL_CTX> objects that are TLS-based, 374*4724848cSchristosand the minimum DTLS protocol to those are DTLS-based. 375*4724848cSchristosThe same applies also to maximum versions set with B<MaxProtocol>. 376*4724848cSchristos 377*4724848cSchristosMore complex OpenSSL library configuration. Add OID and don't enter FIPS mode: 378*4724848cSchristos 379*4724848cSchristos # Default appname: should match "appname" parameter (if any) 380*4724848cSchristos # supplied to CONF_modules_load_file et al. 381*4724848cSchristos openssl_conf = openssl_conf_section 382*4724848cSchristos 383*4724848cSchristos [openssl_conf_section] 384*4724848cSchristos # Configuration module list 385*4724848cSchristos alg_section = evp_sect 386*4724848cSchristos oid_section = new_oids 387*4724848cSchristos 388*4724848cSchristos [evp_sect] 389*4724848cSchristos # This will have no effect as FIPS mode is off by default. 390*4724848cSchristos # Set to "yes" to enter FIPS mode, if supported 391*4724848cSchristos fips_mode = no 392*4724848cSchristos 393*4724848cSchristos [new_oids] 394*4724848cSchristos # New OID, just short name 395*4724848cSchristos newoid1 = 1.2.3.4.1 396*4724848cSchristos # New OID shortname and long name 397*4724848cSchristos newoid2 = New OID 2 long name, 1.2.3.4.2 398*4724848cSchristos 399*4724848cSchristosThe above examples can be used with any application supporting library 400*4724848cSchristosconfiguration if "openssl_conf" is modified to match the appropriate "appname". 401*4724848cSchristos 402*4724848cSchristosFor example if the second sample file above is saved to "example.cnf" then 403*4724848cSchristosthe command line: 404*4724848cSchristos 405*4724848cSchristos OPENSSL_CONF=example.cnf openssl asn1parse -genstr OID:1.2.3.4.1 406*4724848cSchristos 407*4724848cSchristoswill output: 408*4724848cSchristos 409*4724848cSchristos 0:d=0 hl=2 l= 4 prim: OBJECT :newoid1 410*4724848cSchristos 411*4724848cSchristosshowing that the OID "newoid1" has been added as "1.2.3.4.1". 412*4724848cSchristos 413*4724848cSchristos=head1 ENVIRONMENT 414*4724848cSchristos 415*4724848cSchristos=over 4 416*4724848cSchristos 417*4724848cSchristos=item B<OPENSSL_CONF> 418*4724848cSchristos 419*4724848cSchristosThe path to the config file. 420*4724848cSchristosIgnored in set-user-ID and set-group-ID programs. 421*4724848cSchristos 422*4724848cSchristos=item B<OPENSSL_ENGINES> 423*4724848cSchristos 424*4724848cSchristosThe path to the engines directory. 425*4724848cSchristosIgnored in set-user-ID and set-group-ID programs. 426*4724848cSchristos 427*4724848cSchristos=back 428*4724848cSchristos 429*4724848cSchristos=head1 BUGS 430*4724848cSchristos 431*4724848cSchristosCurrently there is no way to include characters using the octal B<\nnn> 432*4724848cSchristosform. Strings are all null terminated so nulls cannot form part of 433*4724848cSchristosthe value. 434*4724848cSchristos 435*4724848cSchristosThe escaping isn't quite right: if you want to use sequences like B<\n> 436*4724848cSchristosyou can't use any quote escaping on the same line. 437*4724848cSchristos 438*4724848cSchristosFiles are loaded in a single pass. This means that a variable expansion 439*4724848cSchristoswill only work if the variables referenced are defined earlier in the 440*4724848cSchristosfile. 441*4724848cSchristos 442*4724848cSchristos=head1 SEE ALSO 443*4724848cSchristos 444*4724848cSchristosL<x509(1)>, L<req(1)>, L<ca(1)> 445*4724848cSchristos 446*4724848cSchristos=head1 COPYRIGHT 447*4724848cSchristos 448*4724848cSchristosCopyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved. 449*4724848cSchristos 450*4724848cSchristosLicensed under the OpenSSL license (the "License"). You may not use 451*4724848cSchristosthis file except in compliance with the License. You can obtain a copy 452*4724848cSchristosin the file LICENSE in the source distribution or at 453*4724848cSchristosL<https://www.openssl.org/source/license.html>. 454*4724848cSchristos 455*4724848cSchristos=cut 456