Update copyright year
[openssl.git] / doc / man5 / x509v3_config.pod
1 =pod
2
3 =head1 NAME
4
5 x509v3_config - X509 V3 certificate extension configuration format
6
7 =head1 DESCRIPTION
8
9 Several OpenSSL commands can add extensions to a certificate or
10 certificate request based on the contents of a configuration file
11 and CLI options such as B<-addext>.
12 The syntax of configuration files is described in L<config(5)>.
13 The commands typically have an option to specify the name of the configuration
14 file, and a section within that file; see the documentation of the
15 individual command for details.
16
17 This page uses B<extensions> as the name of the section, when needed
18 in examples.
19
20 Each entry in the extension section takes the form:
21
22  name = [critical, ]value(s)
23
24 If B<critical> is present then the extension will be marked as critical.
25
26 If multiple entries are processed for the same extension name,
27 later entries override earlier ones with the same name.
28
29 The format of B<values> depends on the value of B<name>, many have a
30 type-value pairing where the type and value are separated by a colon.
31 There are four main types of extension:
32
33  string
34  multi-valued
35  raw
36  arbitrary
37
38 Each is described in the following paragraphs.
39
40 String extensions simply have a string which contains either the value itself
41 or how it is obtained.
42
43 Multi-valued extensions have a short form and a long form. The short form
44 is a comma-separated list of names and values:
45
46  basicConstraints = critical, CA:true, pathlen:1
47
48 The long form allows the values to be placed in a separate section:
49
50  [extensions]
51  basicConstraints = critical, @basic_constraints
52
53  [basic_constraints]
54  CA = true
55  pathlen = 1
56
57 Both forms are equivalent.
58
59 If an extension is multi-value and a field value must contain a comma the long
60 form must be used otherwise the comma would be misinterpreted as a field
61 separator. For example:
62
63  subjectAltName = URI:ldap://somehost.com/CN=foo,OU=bar
64
65 will produce an error but the equivalent form:
66
67  [extensions]
68  subjectAltName = @subject_alt_section
69
70  [subject_alt_section]
71  subjectAltName = URI:ldap://somehost.com/CN=foo,OU=bar
72
73 is valid.
74
75 OpenSSL does not support multiple occurrences of the same field within a
76 section. In this example:
77
78  [extensions]
79  subjectAltName = @alt_section
80
81  [alt_section]
82  email = steve@here
83  email = steve@there
84
85 will only recognize the last value.  To specify multiple values append a
86 numeric identifier, as shown here:
87
88  [extensions]
89  subjectAltName = @alt_section
90
91  [alt_section]
92  email.1 = steve@here
93  email.2 = steve@there
94
95 The syntax of raw extensions is defined by the source code that parses
96 the extension but should be documened.
97 See L</Certificate Policies> for an example of a raw extension.
98
99 If an extension type is unsupported, then the I<arbitrary> extension syntax
100 must be used, see the L</ARBITRARY EXTENSIONS> section for more details.
101
102 =head1 STANDARD EXTENSIONS
103
104 The following sections describe the syntax of each supported extension.
105 They do not define the semantics of the extension.
106
107 =head2 Basic Constraints
108
109 This is a multi-valued extension which indicates whether a certificate is
110 a CA certificate. The first value is B<CA> followed by B<TRUE> or
111 B<FALSE>. If B<CA> is B<TRUE> then an optional B<pathlen> name followed by a
112 nonnegative value can be included.
113
114 For example:
115
116  basicConstraints = CA:TRUE
117
118  basicConstraints = CA:FALSE
119
120  basicConstraints = critical, CA:TRUE, pathlen:1
121
122 A CA certificate I<must> include the B<basicConstraints> name with the B<CA>
123 parameter set to B<TRUE>. An end-user certificate must either have B<CA:FALSE>
124 or omit the extension entirely.
125 The B<pathlen> parameter specifies the maximum number of CAs that can appear
126 below this one in a chain. A B<pathlen> of zero means the CA cannot sign
127 any sub-CA's, and can only sign end-entity certificates.
128
129 =head2 Key Usage
130
131 Key usage is a multi-valued extension consisting of a list of names of
132 the permitted key usages.  The defined values are: C<digitalSignature>,
133 C<nonRepudiation>, C<keyEncipherment>, C<dataEncipherment>, C<keyAgreement>,
134 C<keyCertSign>, C<cRLSign>, C<encipherOnly>, and C<decipherOnly>.
135
136 Examples:
137
138  keyUsage = digitalSignature, nonRepudiation
139
140  keyUsage = critical, keyCertSign
141
142 =head2 Extended Key Usage
143
144 This extension consists of a list of values indicating purposes for which
145 the certificate public key can be used for, Each value can be either a
146 short text name or an OID.
147 The following text names, and their intended meaning, are known:
148
149  Value                  Meaning
150  -----                  -------
151  serverAuth             SSL/TLS Web Server Authentication
152  clientAuth             SSL/TLS Web Client Authentication
153  codeSigning            Code signing
154  emailProtection        E-mail Protection (S/MIME)
155  timeStamping           Trusted Timestamping
156  OCSPSigning            OCSP Signing
157  ipsecIKE               ipsec Internet Key Exchange
158  msCodeInd              Microsoft Individual Code Signing (authenticode)
159  msCodeCom              Microsoft Commercial Code Signing (authenticode)
160  msCTLSign              Microsoft Trust List Signing
161  msEFS                  Microsoft Encrypted File System
162
163 Examples:
164
165  extendedKeyUsage = critical, codeSigning, 1.2.3.4
166
167  extendedKeyUsage = serverAuth, clientAuth
168
169 =head2 Subject Key Identifier
170
171 The SKID extension specification has a value with three choices.
172 If the value is the word B<none> then no SKID extension will be included.
173 If the value is the word B<hash>, or by default for the B<x509>, B<req>, and
174 B<ca> apps, the process specified in RFC 5280 section 4.2.1.2. (1) is followed:
175 The keyIdentifier is composed of the 160-bit SHA-1 hash of the value of the BIT
176 STRING subjectPublicKey (excluding the tag, length, and number of unused bits).
177
178 Otherwise, the value must be a hex string (possibly with C<:> separating bytes)
179 to output directly, however, this is strongly discouraged.
180
181 Example:
182
183  subjectKeyIdentifier = hash
184
185 =head2 Authority Key Identifier
186
187 The AKID extension specification may have the value B<none>
188 indicating that no AKID shall be included.
189 Otherwise it may have the value B<keyid> or B<issuer>
190 or both of them, separated by C<,>.
191 Either or both can have the option B<always>,
192 indicated by putting a colon C<:> between the value and this option.
193 By default the B<x509>, B<req>, and B<ca> apps behave as if
194 "none" was given for self-signed certificates and "keyid, issuer" otherwise.
195
196 If B<keyid> is present, an attempt is made to compute the hash of the public key
197 corresponding to the signing key in case the certificate is self-signed,
198 or else to copy the subject key identifier (SKID) from the issuer certificate.
199 If this fails and the option B<always> is present, an error is returned.
200
201 If B<issuer> is present, and in addition it has the option B<always> specified
202 or B<keyid> is not present,
203 then the issuer DN and serial number are copied from the issuer certificate.
204
205 Examples:
206
207  authorityKeyIdentifier = keyid, issuer
208
209  authorityKeyIdentifier = keyid, issuer:always
210
211 =head2 Subject Alternative Name
212
213 This is a multi-valued extension that supports several types of name
214 identifier, including
215 B<email> (an email address),
216 B<URI> (a uniform resource indicator),
217 B<DNS> (a DNS domain name),
218 B<RID> (a registered ID: OBJECT IDENTIFIER),
219 B<IP> (an IP address),
220 B<dirName> (a distinguished name),
221 and B<otherName>.
222 The syntax of each is described in the following paragraphs.
223
224 The B<email> option has a special C<copy> value, which will automatically
225 include any email addresses contained in the certificate subject name in
226 the extension.
227
228 The IP address used in the B<IP> option can be in either IPv4 or IPv6 format.
229
230 The value of B<dirName> is specifies the configuration section containing
231 the distinguished name to use, as a set of name-value pairs.
232 Multi-valued AVAs can be formed by prefacing the name with a B<+> character.
233
234 The value of B<otherName> can include arbitrary data associated with an OID;
235 the value should be the OID followed by a semicolon and the content in specified
236 using the syntax in L<ASN1_generate_nconf(3)>.
237
238 Examples:
239
240  subjectAltName = email:copy, email:my@other.address, URI:http://my.url.here/
241
242  subjectAltName = IP:192.168.7.1
243
244  subjectAltName = IP:13::17
245
246  subjectAltName = email:my@other.address, RID:1.2.3.4
247
248  subjectAltName = otherName:1.2.3.4;UTF8:some other identifier
249
250  [extensions]
251  subjectAltName = dirName:dir_sect
252
253  [dir_sect]
254  C = UK
255  O = My Organization
256  OU = My Unit
257  CN = My Name
258
259 Non-ASCII Email Address conforming the syntax defined in Section 3.3 of RFC 6531
260 are provided as otherName.SmtpUTF8Mailbox. According to RFC 8398, the email
261 address should be provided as UTF8String. To enforce the valid representation in
262 the certificate, the SmtpUTF8Mailbox should be provided as follows
263
264  subjectAltName=@alts
265  [alts]
266  otherName = 1.3.6.1.5.5.7.8.9;FORMAT:UTF8,UTF8String:nonasciiname.example.com
267
268 =head2 Issuer Alternative Name
269
270 This extension supports most of the options of subject alternative name;
271 it does not support B<email:copy>.
272 It also adds B<issuer:copy> as an allowed value, which copies any subject
273 alternative names from the issuer certificate, if possible.
274
275 Example:
276
277  issuerAltName = issuer:copy
278
279 =head2 Authority Info Access
280
281 This extension gives details about how to retrieve information that
282 related to the certificate that the CA makes available. The syntax is
283 B<access_id;location>, where B<access_id> is an object identifier
284 (although only a few values are well-known) and B<location> has the same
285 syntax as subject alternative name (except that B<email:copy> is not supported).
286
287 Examples:
288
289  authorityInfoAccess = OCSP;URI:http://ocsp.my.host/
290
291 =head2 CRL distribution points
292
293 This is a multi-valued extension whose values can be either a name-value
294 pair using the same form as subject alternative name or a single value
295 specifying the section name containing all the distribution point values.
296
297 When a name-value pair is used, a DistributionPoint extension will
298 be set with the given value as the fullName field as the distributionPoint
299 value, and the reasons and cRLIssuer fields will be omitted.
300
301 When a single option is used, the value specifies the section, and that
302 section can have the following items:
303
304 =over 4
305
306 =item fullname
307
308 The full name of the distribution point, in the same format as the subject
309 alternative name.
310
311 =item relativename
312
313 The value is taken as a distinguished name fragment that is set as the
314 value of the nameRelativeToCRLIssuer field.
315
316 =item CRLIssuer
317
318 The value must in the same format as the subject alternative name.
319
320 =item reasons
321
322 A multi-value field that contains the reasons for revocation. The recognized
323 values are: C<keyCompromise>, C<CACompromise>, C<affiliationChanged>,
324 C<superseded>, C<cessationOfOperation>, C<certificateHold>,
325 C<privilegeWithdrawn>, and C<AACompromise>.
326
327 =back
328
329 Only one of B<fullname> or B<relativename> should be specified.
330
331 Simple examples:
332
333  crlDistributionPoints = URI:http://myhost.com/myca.crl
334
335  crlDistributionPoints = URI:http://my.com/my.crl, URI:http://oth.com/my.crl
336
337 Full distribution point example:
338
339  [extensions]
340  crlDistributionPoints = crldp1_section
341
342  [crldp1_section]
343  fullname = URI:http://myhost.com/myca.crl
344  CRLissuer = dirName:issuer_sect
345  reasons = keyCompromise, CACompromise
346
347  [issuer_sect]
348  C = UK
349  O = Organisation
350  CN = Some Name
351
352 =head2 Issuing Distribution Point
353
354 This extension should only appear in CRLs. It is a multi-valued extension
355 whose syntax is similar to the "section" pointed to by the CRL distribution
356 points extension. The following names have meaning:
357
358 =over 4
359
360 =item fullname
361
362 The full name of the distribution point, in the same format as the subject
363 alternative name.
364
365 =item relativename
366
367 The value is taken as a distinguished name fragment that is set as the
368 value of the nameRelativeToCRLIssuer field.
369
370 =item onlysomereasons
371
372 A multi-value field that contains the reasons for revocation. The recognized
373 values are: C<keyCompromise>, C<CACompromise>, C<affiliationChanged>,
374 C<superseded>, C<cessationOfOperation>, C<certificateHold>,
375 C<privilegeWithdrawn>, and C<AACompromise>.
376
377 =item onlyuser, onlyCA, onlyAA, indirectCRL
378
379 The value for each of these names is a boolean.
380
381 =back
382
383 Example:
384
385  [extensions]
386  issuingDistributionPoint = critical, @idp_section
387
388  [idp_section]
389  fullname = URI:http://myhost.com/myca.crl
390  indirectCRL = TRUE
391  onlysomereasons = keyCompromise, CACompromise
392
393 =head2 Certificate Policies
394
395 This is a I<raw> extension that supports all of the defined fields of the
396 certificate extension.
397
398 Policies without qualifiers are specified by giving the OID.
399 Multiple policies are comma-separated. For example:
400
401  certificatePolicies = 1.2.4.5, 1.1.3.4
402
403 To include policy qualifiers, use the "@section" syntax to point to a
404 section that specifies all the information.
405
406 The section referred to must include the policy OID using the name
407 B<policyIdentifier>. cPSuri qualifiers can be included using the syntax:
408
409  CPS.nnn = value
410
411 where C<nnn> is a number.
412
413 userNotice qualifiers can be set using the syntax:
414
415  userNotice.nnn = @notice
416
417 The value of the userNotice qualifier is specified in the relevant section.
418 This section can include B<explicitText>, B<organization>, and B<noticeNumbers>
419 options. explicitText and organization are text strings, noticeNumbers is a
420 comma separated list of numbers. The organization and noticeNumbers options
421 (if included) must BOTH be present. Some software might require
422 the B<ia5org> option at the top level; this changes the encoding from
423 Displaytext to IA5String.
424
425 Example:
426
427  [extensions]
428  certificatePolicies = ia5org, 1.2.3.4, 1.5.6.7.8, @polsect
429
430  [polsect]
431  policyIdentifier = 1.3.5.8
432  CPS.1 = "http://my.host.name/"
433  CPS.2 = "http://my.your.name/"
434  userNotice.1 = @notice
435
436  [notice]
437  explicitText = "Explicit Text Here"
438  organization = "Organisation Name"
439  noticeNumbers = 1, 2, 3, 4
440
441 The character encoding of explicitText can be specified by prefixing the
442 value with B<UTF8>, B<BMP>, or B<VISIBLE> followed by colon. For example:
443
444  [notice]
445  explicitText = "UTF8:Explicit Text Here"
446
447 =head2 Policy Constraints
448
449 This is a multi-valued extension which consisting of the names
450 B<requireExplicitPolicy> or B<inhibitPolicyMapping> and a non negative integer
451 value. At least one component must be present.
452
453 Example:
454
455  policyConstraints = requireExplicitPolicy:3
456
457 =head2 Inhibit Any Policy
458
459 This is a string extension whose value must be a non negative integer.
460
461 Example:
462
463  inhibitAnyPolicy = 2
464
465 =head2 Name Constraints
466
467 This is a multi-valued extension. The name should
468 begin with the word B<permitted> or B<excluded> followed by a B<;>. The rest of
469 the name and the value follows the syntax of subjectAltName except
470 B<email:copy>
471 is not supported and the B<IP> form should consist of an IP addresses and
472 subnet mask separated by a B</>.
473
474 Examples:
475
476  nameConstraints = permitted;IP:192.168.0.0/255.255.0.0
477
478  nameConstraints = permitted;email:.somedomain.com
479
480  nameConstraints = excluded;email:.com
481
482 =head2 OCSP No Check
483
484 This is a string extension. It is parsed, but ignored.
485
486 Example:
487
488  noCheck = ignored
489
490 =head2 TLS Feature (aka Must Staple)
491
492 This is a multi-valued extension consisting of a list of TLS extension
493 identifiers. Each identifier may be a number (0..65535) or a supported name.
494 When a TLS client sends a listed extension, the TLS server is expected to
495 include that extension in its reply.
496
497 The supported names are: B<status_request> and B<status_request_v2>.
498
499 Example:
500
501  tlsfeature = status_request
502
503 =head1 DEPRECATED EXTENSIONS
504
505 The following extensions are non standard, Netscape specific and largely
506 obsolete. Their use in new applications is discouraged.
507
508 =head2 Netscape String extensions
509
510 Netscape Comment (B<nsComment>) is a string extension containing a comment
511 which will be displayed when the certificate is viewed in some browsers.
512 Other extensions of this type are: B<nsBaseUrl>,
513 B<nsRevocationUrl>, B<nsCaRevocationUrl>, B<nsRenewalUrl>, B<nsCaPolicyUrl>
514 and B<nsSslServerName>.
515
516 =head2 Netscape Certificate Type
517
518 This is a multi-valued extensions which consists of a list of flags to be
519 included. It was used to indicate the purposes for which a certificate could
520 be used. The basicConstraints, keyUsage and extended key usage extensions are
521 now used instead.
522
523 Acceptable values for nsCertType are: B<client>, B<server>, B<email>,
524 B<objsign>, B<reserved>, B<sslCA>, B<emailCA>, B<objCA>.
525
526 =head1 ARBITRARY EXTENSIONS
527
528 If an extension is not supported by the OpenSSL code then it must be encoded
529 using the arbitrary extension format. It is also possible to use the arbitrary
530 format for supported extensions. Extreme care should be taken to ensure that
531 the data is formatted correctly for the given extension type.
532
533 There are two ways to encode arbitrary extensions.
534
535 The first way is to use the word ASN1 followed by the extension content
536 using the same syntax as L<ASN1_generate_nconf(3)>.
537 For example:
538
539  [extensions]
540  1.2.3.4 = critical, ASN1:UTF8String:Some random data
541  1.2.3.4.1 = ASN1:SEQUENCE:seq_sect
542
543  [seq_sect]
544  field1 = UTF8:field1
545  field2 = UTF8:field2
546
547 It is also possible to use the word DER to include the raw encoded data in any
548 extension.
549
550  1.2.3.4 = critical, DER:01:02:03:04
551  1.2.3.4.1 = DER:01020304
552
553 The value following DER is a hex dump of the DER encoding of the extension
554 Any extension can be placed in this form to override the default behaviour.
555 For example:
556
557  basicConstraints = critical, DER:00:01:02:03
558
559 =head1 WARNINGS
560
561 There is no guarantee that a specific implementation will process a given
562 extension. It may therefore be sometimes possible to use certificates for
563 purposes prohibited by their extensions because a specific application does
564 not recognize or honour the values of the relevant extensions.
565
566 The DER and ASN1 options should be used with caution. It is possible to create
567 invalid extensions if they are not used carefully.
568
569 =head1 SEE ALSO
570
571 L<openssl-req(1)>, L<openssl-ca(1)>, L<openssl-x509(1)>,
572 L<ASN1_generate_nconf(3)>
573
574 =head1 COPYRIGHT
575
576 Copyright 2004-2021 The OpenSSL Project Authors. All Rights Reserved.
577
578 Licensed under the Apache License 2.0 (the "License").  You may not use
579 this file except in compliance with the License.  You can obtain a copy
580 in the file LICENSE in the source distribution or at
581 L<https://www.openssl.org/source/license.html>.
582
583 =cut