x509v3_config.pod 17 KB

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