1*2175Sjp161948 2*2175Sjp161948=pod 3*2175Sjp161948 4*2175Sjp161948=for comment openssl_manual_section:5 5*2175Sjp161948 6*2175Sjp161948=head1 NAME 7*2175Sjp161948 8*2175Sjp161948config - OpenSSL CONF library configuration files 9*2175Sjp161948 10*2175Sjp161948=head1 DESCRIPTION 11*2175Sjp161948 12*2175Sjp161948The OpenSSL CONF library can be used to read configuration files. 13*2175Sjp161948It is used for the OpenSSL master configuration file B<openssl.cnf> 14*2175Sjp161948and in a few other places like B<SPKAC> files and certificate extension 15*2175Sjp161948files for the B<x509> utility. OpenSSL applications can also use the 16*2175Sjp161948CONF library for their own purposes. 17*2175Sjp161948 18*2175Sjp161948A configuration file is divided into a number of sections. Each section 19*2175Sjp161948starts with a line B<[ section_name ]> and ends when a new section is 20*2175Sjp161948started or end of file is reached. A section name can consist of 21*2175Sjp161948alphanumeric characters and underscores. 22*2175Sjp161948 23*2175Sjp161948The first section of a configuration file is special and is referred 24*2175Sjp161948to as the B<default> section this is usually unnamed and is from the 25*2175Sjp161948start of file until the first named section. When a name is being looked up 26*2175Sjp161948it is first looked up in a named section (if any) and then the 27*2175Sjp161948default section. 28*2175Sjp161948 29*2175Sjp161948The environment is mapped onto a section called B<ENV>. 30*2175Sjp161948 31*2175Sjp161948Comments can be included by preceding them with the B<#> character 32*2175Sjp161948 33*2175Sjp161948Each section in a configuration file consists of a number of name and 34*2175Sjp161948value pairs of the form B<name=value> 35*2175Sjp161948 36*2175Sjp161948The B<name> string can contain any alphanumeric characters as well as 37*2175Sjp161948a few punctuation symbols such as B<.> B<,> B<;> and B<_>. 38*2175Sjp161948 39*2175Sjp161948The B<value> string consists of the string following the B<=> character 40*2175Sjp161948until end of line with any leading and trailing white space removed. 41*2175Sjp161948 42*2175Sjp161948The value string undergoes variable expansion. This can be done by 43*2175Sjp161948including the form B<$var> or B<${var}>: this will substitute the value 44*2175Sjp161948of the named variable in the current section. It is also possible to 45*2175Sjp161948substitute a value from another section using the syntax B<$section::name> 46*2175Sjp161948or B<${section::name}>. By using the form B<$ENV::name> environment 47*2175Sjp161948variables can be substituted. It is also possible to assign values to 48*2175Sjp161948environment variables by using the name B<ENV::name>, this will work 49*2175Sjp161948if the program looks up environment variables using the B<CONF> library 50*2175Sjp161948instead of calling B<getenv()> directly. 51*2175Sjp161948 52*2175Sjp161948It is possible to escape certain characters by using any kind of quote 53*2175Sjp161948or the B<\> character. By making the last character of a line a B<\> 54*2175Sjp161948a B<value> string can be spread across multiple lines. In addition 55*2175Sjp161948the sequences B<\n>, B<\r>, B<\b> and B<\t> are recognized. 56*2175Sjp161948 57*2175Sjp161948=head1 OPENSSL LIBRARY CONFIGURATION 58*2175Sjp161948 59*2175Sjp161948In OpenSSL 0.9.7 and later applications can automatically configure certain 60*2175Sjp161948aspects of OpenSSL using the master OpenSSL configuration file, or optionally 61*2175Sjp161948an alternative configuration file. The B<openssl> utility includes this 62*2175Sjp161948functionality: any sub command uses the master OpenSSL configuration file 63*2175Sjp161948unless an option is used in the sub command to use an alternative configuration 64*2175Sjp161948file. 65*2175Sjp161948 66*2175Sjp161948To enable library configuration the default section needs to contain an 67*2175Sjp161948appropriate line which points to the main configuration section. The default 68*2175Sjp161948name is B<openssl_conf> which is used by the B<openssl> utility. Other 69*2175Sjp161948applications may use an alternative name such as B<myapplicaton_conf>. 70*2175Sjp161948 71*2175Sjp161948The configuration section should consist of a set of name value pairs which 72*2175Sjp161948contain specific module configuration information. The B<name> represents 73*2175Sjp161948the name of the I<configuration module> the meaning of the B<value> is 74*2175Sjp161948module specific: it may, for example, represent a further configuration 75*2175Sjp161948section containing configuration module specific information. E.g. 76*2175Sjp161948 77*2175Sjp161948 openssl_conf = openssl_init 78*2175Sjp161948 79*2175Sjp161948 [openssl_init] 80*2175Sjp161948 81*2175Sjp161948 oid_section = new_oids 82*2175Sjp161948 engines = engine_section 83*2175Sjp161948 84*2175Sjp161948 [new_oids] 85*2175Sjp161948 86*2175Sjp161948 ... new oids here ... 87*2175Sjp161948 88*2175Sjp161948 [engine_section] 89*2175Sjp161948 90*2175Sjp161948 ... engine stuff here ... 91*2175Sjp161948 92*2175Sjp161948Currently there are two configuration modules. One for ASN1 objects another 93*2175Sjp161948for ENGINE configuration. 94*2175Sjp161948 95*2175Sjp161948=head2 ASN1 OBJECT CONFIGURATION MODULE 96*2175Sjp161948 97*2175Sjp161948This module has the name B<oid_section>. The value of this variable points 98*2175Sjp161948to a section containing name value pairs of OIDs: the name is the OID short 99*2175Sjp161948and long name, the value is the numerical form of the OID. Although some of 100*2175Sjp161948the B<openssl> utility sub commands already have their own ASN1 OBJECT section 101*2175Sjp161948functionality not all do. By using the ASN1 OBJECT configuration module 102*2175Sjp161948B<all> the B<openssl> utility sub commands can see the new objects as well 103*2175Sjp161948as any compliant applications. For example: 104*2175Sjp161948 105*2175Sjp161948 [new_oids] 106*2175Sjp161948 107*2175Sjp161948 some_new_oid = 1.2.3.4 108*2175Sjp161948 some_other_oid = 1.2.3.5 109*2175Sjp161948 110*2175Sjp161948In OpenSSL 0.9.8 it is also possible to set the value to the long name followed 111*2175Sjp161948by a comma and the numerical OID form. For example: 112*2175Sjp161948 113*2175Sjp161948 shortName = some object long name, 1.2.3.4 114*2175Sjp161948 115*2175Sjp161948=head2 ENGINE CONFIGURATION MODULE 116*2175Sjp161948 117*2175Sjp161948This ENGINE configuration module has the name B<engines>. The value of this 118*2175Sjp161948variable points to a section containing further ENGINE configuration 119*2175Sjp161948information. 120*2175Sjp161948 121*2175Sjp161948The section pointed to by B<engines> is a table of engine names (though see 122*2175Sjp161948B<engine_id> below) and further sections containing configuration informations 123*2175Sjp161948specific to each ENGINE. 124*2175Sjp161948 125*2175Sjp161948Each ENGINE specific section is used to set default algorithms, load 126*2175Sjp161948dynamic, perform initialization and send ctrls. The actual operation performed 127*2175Sjp161948depends on the I<command> name which is the name of the name value pair. The 128*2175Sjp161948currently supported commands are listed below. 129*2175Sjp161948 130*2175Sjp161948For example: 131*2175Sjp161948 132*2175Sjp161948 [engine_section] 133*2175Sjp161948 134*2175Sjp161948 # Configure ENGINE named "foo" 135*2175Sjp161948 foo = foo_section 136*2175Sjp161948 # Configure ENGINE named "bar" 137*2175Sjp161948 bar = bar_section 138*2175Sjp161948 139*2175Sjp161948 [foo_section] 140*2175Sjp161948 ... foo ENGINE specific commands ... 141*2175Sjp161948 142*2175Sjp161948 [bar_section] 143*2175Sjp161948 ... "bar" ENGINE specific commands ... 144*2175Sjp161948 145*2175Sjp161948The command B<engine_id> is used to give the ENGINE name. If used this 146*2175Sjp161948command must be first. For example: 147*2175Sjp161948 148*2175Sjp161948 [engine_section] 149*2175Sjp161948 # This would normally handle an ENGINE named "foo" 150*2175Sjp161948 foo = foo_section 151*2175Sjp161948 152*2175Sjp161948 [foo_section] 153*2175Sjp161948 # Override default name and use "myfoo" instead. 154*2175Sjp161948 engine_id = myfoo 155*2175Sjp161948 156*2175Sjp161948The command B<dynamic_path> loads and adds an ENGINE from the given path. It 157*2175Sjp161948is equivalent to sending the ctrls B<SO_PATH> with the path argument followed 158*2175Sjp161948by B<LIST_ADD> with value 2 and B<LOAD> to the dynamic ENGINE. If this is 159*2175Sjp161948not the required behaviour then alternative ctrls can be sent directly 160*2175Sjp161948to the dynamic ENGINE using ctrl commands. 161*2175Sjp161948 162*2175Sjp161948The command B<init> determines whether to initialize the ENGINE. If the value 163*2175Sjp161948is B<0> the ENGINE will not be initialized, if B<1> and attempt it made to 164*2175Sjp161948initialized the ENGINE immediately. If the B<init> command is not present 165*2175Sjp161948then an attempt will be made to initialize the ENGINE after all commands in 166*2175Sjp161948its section have been processed. 167*2175Sjp161948 168*2175Sjp161948The command B<default_algorithms> sets the default algorithms an ENGINE will 169*2175Sjp161948supply using the functions B<ENGINE_set_default_string()> 170*2175Sjp161948 171*2175Sjp161948If the name matches none of the above command names it is assumed to be a 172*2175Sjp161948ctrl command which is sent to the ENGINE. The value of the command is the 173*2175Sjp161948argument to the ctrl command. If the value is the string B<EMPTY> then no 174*2175Sjp161948value is sent to the command. 175*2175Sjp161948 176*2175Sjp161948For example: 177*2175Sjp161948 178*2175Sjp161948 179*2175Sjp161948 [engine_section] 180*2175Sjp161948 181*2175Sjp161948 # Configure ENGINE named "foo" 182*2175Sjp161948 foo = foo_section 183*2175Sjp161948 184*2175Sjp161948 [foo_section] 185*2175Sjp161948 # Load engine from DSO 186*2175Sjp161948 dynamic_path = /some/path/fooengine.so 187*2175Sjp161948 # A foo specific ctrl. 188*2175Sjp161948 some_ctrl = some_value 189*2175Sjp161948 # Another ctrl that doesn't take a value. 190*2175Sjp161948 other_ctrl = EMPTY 191*2175Sjp161948 # Supply all default algorithms 192*2175Sjp161948 default_algorithms = ALL 193*2175Sjp161948 194*2175Sjp161948=head1 NOTES 195*2175Sjp161948 196*2175Sjp161948If a configuration file attempts to expand a variable that doesn't exist 197*2175Sjp161948then an error is flagged and the file will not load. This can happen 198*2175Sjp161948if an attempt is made to expand an environment variable that doesn't 199*2175Sjp161948exist. For example in a previous version of OpenSSL the default OpenSSL 200*2175Sjp161948master configuration file used the value of B<HOME> which may not be 201*2175Sjp161948defined on non Unix systems and would cause an error. 202*2175Sjp161948 203*2175Sjp161948This can be worked around by including a B<default> section to provide 204*2175Sjp161948a default value: then if the environment lookup fails the default value 205*2175Sjp161948will be used instead. For this to work properly the default value must 206*2175Sjp161948be defined earlier in the configuration file than the expansion. See 207*2175Sjp161948the B<EXAMPLES> section for an example of how to do this. 208*2175Sjp161948 209*2175Sjp161948If the same variable exists in the same section then all but the last 210*2175Sjp161948value will be silently ignored. In certain circumstances such as with 211*2175Sjp161948DNs the same field may occur multiple times. This is usually worked 212*2175Sjp161948around by ignoring any characters before an initial B<.> e.g. 213*2175Sjp161948 214*2175Sjp161948 1.OU="My first OU" 215*2175Sjp161948 2.OU="My Second OU" 216*2175Sjp161948 217*2175Sjp161948=head1 EXAMPLES 218*2175Sjp161948 219*2175Sjp161948Here is a sample configuration file using some of the features 220*2175Sjp161948mentioned above. 221*2175Sjp161948 222*2175Sjp161948 # This is the default section. 223*2175Sjp161948 224*2175Sjp161948 HOME=/temp 225*2175Sjp161948 RANDFILE= ${ENV::HOME}/.rnd 226*2175Sjp161948 configdir=$ENV::HOME/config 227*2175Sjp161948 228*2175Sjp161948 [ section_one ] 229*2175Sjp161948 230*2175Sjp161948 # We are now in section one. 231*2175Sjp161948 232*2175Sjp161948 # Quotes permit leading and trailing whitespace 233*2175Sjp161948 any = " any variable name " 234*2175Sjp161948 235*2175Sjp161948 other = A string that can \ 236*2175Sjp161948 cover several lines \ 237*2175Sjp161948 by including \\ characters 238*2175Sjp161948 239*2175Sjp161948 message = Hello World\n 240*2175Sjp161948 241*2175Sjp161948 [ section_two ] 242*2175Sjp161948 243*2175Sjp161948 greeting = $section_one::message 244*2175Sjp161948 245*2175Sjp161948This next example shows how to expand environment variables safely. 246*2175Sjp161948 247*2175Sjp161948Suppose you want a variable called B<tmpfile> to refer to a 248*2175Sjp161948temporary filename. The directory it is placed in can determined by 249*2175Sjp161948the the B<TEMP> or B<TMP> environment variables but they may not be 250*2175Sjp161948set to any value at all. If you just include the environment variable 251*2175Sjp161948names and the variable doesn't exist then this will cause an error when 252*2175Sjp161948an attempt is made to load the configuration file. By making use of the 253*2175Sjp161948default section both values can be looked up with B<TEMP> taking 254*2175Sjp161948priority and B</tmp> used if neither is defined: 255*2175Sjp161948 256*2175Sjp161948 TMP=/tmp 257*2175Sjp161948 # The above value is used if TMP isn't in the environment 258*2175Sjp161948 TEMP=$ENV::TMP 259*2175Sjp161948 # The above value is used if TEMP isn't in the environment 260*2175Sjp161948 tmpfile=${ENV::TEMP}/tmp.filename 261*2175Sjp161948 262*2175Sjp161948=head1 BUGS 263*2175Sjp161948 264*2175Sjp161948Currently there is no way to include characters using the octal B<\nnn> 265*2175Sjp161948form. Strings are all null terminated so nulls cannot form part of 266*2175Sjp161948the value. 267*2175Sjp161948 268*2175Sjp161948The escaping isn't quite right: if you want to use sequences like B<\n> 269*2175Sjp161948you can't use any quote escaping on the same line. 270*2175Sjp161948 271*2175Sjp161948Files are loaded in a single pass. This means that an variable expansion 272*2175Sjp161948will only work if the variables referenced are defined earlier in the 273*2175Sjp161948file. 274*2175Sjp161948 275*2175Sjp161948=head1 SEE ALSO 276*2175Sjp161948 277*2175Sjp161948L<x509(1)|x509(1)>, L<req(1)|req(1)>, L<ca(1)|ca(1)> 278*2175Sjp161948 279*2175Sjp161948=cut 280