x509v3_config.pod 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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@example.com
  55. email = steve@example.org
  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@example.com
  62. email.2 = steve@example.org
  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.
  97. Each value can be either a short text name or an OID.
  98. The following text names, and their intended meaning, are known:
  99. Value Meaning according to RFC 5280 etc.
  100. ----- ----------------------------------
  101. serverAuth SSL/TLS WWW Server Authentication
  102. clientAuth SSL/TLS WWW 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. While IETF RFC 5280 says that B<id-kp-serverAuth> and B<id-kp-clientAuth>
  113. are only for WWW use, in practice they are used for all kinds of TLS clients
  114. and servers, and this is what OpenSSL assumes as well.
  115. Examples:
  116. extendedKeyUsage = critical, codeSigning, 1.2.3.4
  117. extendedKeyUsage = serverAuth, clientAuth
  118. =head2 Subject Key Identifier
  119. The SKID extension specification has a value with three choices.
  120. =over 4
  121. =item B<none>
  122. No SKID extension will be included.
  123. =item B<hash>
  124. The process specified in RFC 5280 section 4.2.1.2. (1) is followed:
  125. The keyIdentifier is composed of the 160-bit SHA-1 hash of the value of the BIT
  126. STRING subjectPublicKey (excluding the tag, length, and number of unused bits).
  127. =item A hex string (possibly with C<:> separating bytes)
  128. The provided value is output directly.
  129. This choice is strongly discouraged.
  130. =back
  131. By default the B<x509>, B<req>, and B<ca> apps behave as if B<hash> was given.
  132. Example:
  133. subjectKeyIdentifier = hash
  134. =head2 Authority Key Identifier
  135. The AKID extension specification may have the value B<none>
  136. indicating that no AKID shall be included.
  137. Otherwise it may have the value B<keyid> or B<issuer>
  138. or both of them, separated by C<,>.
  139. Either or both can have the option B<always>,
  140. indicated by putting a colon C<:> between the value and this option.
  141. For self-signed certificates the AKID is suppressed unless B<always> is present.
  142. By default the B<x509>, B<req>, and B<ca> apps behave as if B<none> was given
  143. for self-signed certificates and B<keyid>C<,> B<issuer> otherwise.
  144. If B<keyid> is present, an attempt is made to
  145. copy the subject key identifier (SKID) from the issuer certificate except if
  146. the issuer certificate is the same as the current one and it is not self-signed.
  147. The hash of the public key related to the signing key is taken as fallback
  148. if the issuer certificate is the same as the current certificate.
  149. If B<always> is present but no value can be obtained, an error is returned.
  150. If B<issuer> is present, and in addition it has the option B<always> specified
  151. or B<keyid> is not present,
  152. then the issuer DN and serial number are copied from the issuer certificate.
  153. If this fails, an error is returned.
  154. Examples:
  155. authorityKeyIdentifier = keyid, issuer
  156. authorityKeyIdentifier = keyid, issuer:always
  157. =head2 Subject Alternative Name
  158. This is a multi-valued extension that supports several types of name
  159. identifier, including
  160. B<email> (an email address),
  161. B<URI> (a uniform resource indicator),
  162. B<DNS> (a DNS domain name),
  163. B<RID> (a registered ID: OBJECT IDENTIFIER),
  164. B<IP> (an IP address),
  165. B<dirName> (a distinguished name),
  166. and B<otherName>.
  167. The syntax of each is described in the following paragraphs.
  168. The B<email> option has two special values.
  169. C<copy> will automatically include any email addresses
  170. contained in the certificate subject name in the extension.
  171. C<move> will automatically move any email addresses
  172. from the certificate subject name to the extension.
  173. The IP address used in the B<IP> option can be in either IPv4 or IPv6 format.
  174. The value of B<dirName> is specifies the configuration section containing
  175. the distinguished name to use, as a set of name-value pairs.
  176. Multi-valued AVAs can be formed by prefacing the name with a B<+> character.
  177. The value of B<otherName> can include arbitrary data associated with an OID;
  178. the value should be the OID followed by a semicolon and the content in specified
  179. using the syntax in L<ASN1_generate_nconf(3)>.
  180. Examples:
  181. subjectAltName = email:copy, email:my@example.com, URI:http://my.example.com/
  182. subjectAltName = IP:192.168.7.1
  183. subjectAltName = IP:13::17
  184. subjectAltName = email:my@example.com, RID:1.2.3.4
  185. subjectAltName = otherName:1.2.3.4;UTF8:some other identifier
  186. [extensions]
  187. subjectAltName = dirName:dir_sect
  188. [dir_sect]
  189. C = UK
  190. O = My Organization
  191. OU = My Unit
  192. CN = My Name
  193. Non-ASCII Email Address conforming the syntax defined in Section 3.3 of RFC 6531
  194. are provided as otherName.SmtpUTF8Mailbox. According to RFC 8398, the email
  195. address should be provided as UTF8String. To enforce the valid representation in
  196. the certificate, the SmtpUTF8Mailbox should be provided as follows
  197. subjectAltName=@alts
  198. [alts]
  199. otherName = 1.3.6.1.5.5.7.8.9;FORMAT:UTF8,UTF8String:nonasciiname.example.com
  200. =head2 Issuer Alternative Name
  201. This extension supports most of the options of subject alternative name;
  202. it does not support B<email:copy>.
  203. It also adds B<issuer:copy> as an allowed value, which copies any subject
  204. alternative names from the issuer certificate, if possible.
  205. Example:
  206. issuerAltName = issuer:copy
  207. =head2 Authority Info Access
  208. This extension gives details about how to retrieve information that
  209. related to the certificate that the CA makes available. The syntax is
  210. B<access_id;location>, where B<access_id> is an object identifier
  211. (although only a few values are well-known) and B<location> has the same
  212. syntax as subject alternative name (except that B<email:copy> is not supported).
  213. Possible values for access_id include B<OCSP> (OCSP responder),
  214. B<caIssuers> (CA Issuers),
  215. B<ad_timestamping> (AD Time Stamping),
  216. B<AD_DVCS> (ad dvcs),
  217. B<caRepository> (CA Repository).
  218. Examples:
  219. authorityInfoAccess = OCSP;URI:http://ocsp.example.com/,caIssuers;URI:http://myca.example.com/ca.cer
  220. authorityInfoAccess = OCSP;URI:http://ocsp.example.com/
  221. =head2 CRL distribution points
  222. This is a multi-valued extension whose values can be either a name-value
  223. pair using the same form as subject alternative name or a single value
  224. specifying the section name containing all the distribution point values.
  225. When a name-value pair is used, a DistributionPoint extension will
  226. be set with the given value as the fullName field as the distributionPoint
  227. value, and the reasons and cRLIssuer fields will be omitted.
  228. When a single option is used, the value specifies the section, and that
  229. section can have the following items:
  230. =over 4
  231. =item fullname
  232. The full name of the distribution point, in the same format as the subject
  233. alternative name.
  234. =item relativename
  235. The value is taken as a distinguished name fragment that is set as the
  236. value of the nameRelativeToCRLIssuer field.
  237. =item CRLIssuer
  238. The value must in the same format as the subject alternative name.
  239. =item reasons
  240. A multi-value field that contains the reasons for revocation. The recognized
  241. values are: C<keyCompromise>, C<CACompromise>, C<affiliationChanged>,
  242. C<superseded>, C<cessationOfOperation>, C<certificateHold>,
  243. C<privilegeWithdrawn>, and C<AACompromise>.
  244. =back
  245. Only one of B<fullname> or B<relativename> should be specified.
  246. Simple examples:
  247. crlDistributionPoints = URI:http://example.com/myca.crl
  248. crlDistributionPoints = URI:http://example.com/myca.crl, URI:http://example.org/my.crl
  249. Full distribution point example:
  250. [extensions]
  251. crlDistributionPoints = crldp1_section
  252. [crldp1_section]
  253. fullname = URI:http://example.com/myca.crl
  254. CRLissuer = dirName:issuer_sect
  255. reasons = keyCompromise, CACompromise
  256. [issuer_sect]
  257. C = UK
  258. O = Organisation
  259. CN = Some Name
  260. =head2 Issuing Distribution Point
  261. This extension should only appear in CRLs. It is a multi-valued extension
  262. whose syntax is similar to the "section" pointed to by the CRL distribution
  263. points extension. The following names have meaning:
  264. =over 4
  265. =item fullname
  266. The full name of the distribution point, in the same format as the subject
  267. alternative name.
  268. =item relativename
  269. The value is taken as a distinguished name fragment that is set as the
  270. value of the nameRelativeToCRLIssuer field.
  271. =item onlysomereasons
  272. A multi-value field that contains the reasons for revocation. The recognized
  273. values are: C<keyCompromise>, C<CACompromise>, C<affiliationChanged>,
  274. C<superseded>, C<cessationOfOperation>, C<certificateHold>,
  275. C<privilegeWithdrawn>, and C<AACompromise>.
  276. =item onlyuser, onlyCA, onlyAA, indirectCRL
  277. The value for each of these names is a boolean.
  278. =back
  279. Example:
  280. [extensions]
  281. issuingDistributionPoint = critical, @idp_section
  282. [idp_section]
  283. fullname = URI:http://example.com/myca.crl
  284. indirectCRL = TRUE
  285. onlysomereasons = keyCompromise, CACompromise
  286. =head2 Certificate Policies
  287. This is a I<raw> extension that supports all of the defined fields of the
  288. certificate extension.
  289. Policies without qualifiers are specified by giving the OID.
  290. Multiple policies are comma-separated. For example:
  291. certificatePolicies = 1.2.4.5, 1.1.3.4
  292. To include policy qualifiers, use the "@section" syntax to point to a
  293. section that specifies all the information.
  294. The section referred to must include the policy OID using the name
  295. B<policyIdentifier>. cPSuri qualifiers can be included using the syntax:
  296. CPS.nnn = value
  297. where C<nnn> is a number.
  298. userNotice qualifiers can be set using the syntax:
  299. userNotice.nnn = @notice
  300. The value of the userNotice qualifier is specified in the relevant section.
  301. This section can include B<explicitText>, B<organization>, and B<noticeNumbers>
  302. options. explicitText and organization are text strings, noticeNumbers is a
  303. comma separated list of numbers. The organization and noticeNumbers options
  304. (if included) must BOTH be present. Some software might require
  305. the B<ia5org> option at the top level; this changes the encoding from
  306. Displaytext to IA5String.
  307. Example:
  308. [extensions]
  309. certificatePolicies = ia5org, 1.2.3.4, 1.5.6.7.8, @polsect
  310. [polsect]
  311. policyIdentifier = 1.3.5.8
  312. CPS.1 = "http://my.host.example.com/"
  313. CPS.2 = "http://my.your.example.com/"
  314. userNotice.1 = @notice
  315. [notice]
  316. explicitText = "Explicit Text Here"
  317. organization = "Organisation Name"
  318. noticeNumbers = 1, 2, 3, 4
  319. The character encoding of explicitText can be specified by prefixing the
  320. value with B<UTF8>, B<BMP>, or B<VISIBLE> followed by colon. For example:
  321. [notice]
  322. explicitText = "UTF8:Explicit Text Here"
  323. =head2 Policy Constraints
  324. This is a multi-valued extension which consisting of the names
  325. B<requireExplicitPolicy> or B<inhibitPolicyMapping> and a non negative integer
  326. value. At least one component must be present.
  327. Example:
  328. policyConstraints = requireExplicitPolicy:3
  329. =head2 Inhibit Any Policy
  330. This is a string extension whose value must be a non negative integer.
  331. Example:
  332. inhibitAnyPolicy = 2
  333. =head2 Name Constraints
  334. This is a multi-valued extension. The name should
  335. begin with the word B<permitted> or B<excluded> followed by a B<;>. The rest of
  336. the name and the value follows the syntax of subjectAltName except
  337. B<email:copy>
  338. is not supported and the B<IP> form should consist of an IP addresses and
  339. subnet mask separated by a B</>.
  340. Examples:
  341. nameConstraints = permitted;IP:192.168.0.0/255.255.0.0
  342. nameConstraints = permitted;email:.example.com
  343. nameConstraints = excluded;email:.com
  344. =head2 OCSP No Check
  345. This is a string extension. It is parsed, but ignored.
  346. Example:
  347. noCheck = ignored
  348. =head2 TLS Feature (aka Must Staple)
  349. This is a multi-valued extension consisting of a list of TLS extension
  350. identifiers. Each identifier may be a number (0..65535) or a supported name.
  351. When a TLS client sends a listed extension, the TLS server is expected to
  352. include that extension in its reply.
  353. The supported names are: B<status_request> and B<status_request_v2>.
  354. Example:
  355. tlsfeature = status_request
  356. =head1 DEPRECATED EXTENSIONS
  357. The following extensions are non standard, Netscape specific and largely
  358. obsolete. Their use in new applications is discouraged.
  359. =head2 Netscape String extensions
  360. Netscape Comment (B<nsComment>) is a string extension containing a comment
  361. which will be displayed when the certificate is viewed in some browsers.
  362. Other extensions of this type are: B<nsBaseUrl>,
  363. B<nsRevocationUrl>, B<nsCaRevocationUrl>, B<nsRenewalUrl>, B<nsCaPolicyUrl>
  364. and B<nsSslServerName>.
  365. =head2 Netscape Certificate Type
  366. This is a multi-valued extensions which consists of a list of flags to be
  367. included. It was used to indicate the purposes for which a certificate could
  368. be used. The basicConstraints, keyUsage and extended key usage extensions are
  369. now used instead.
  370. Acceptable values for nsCertType are: B<client>, B<server>, B<email>,
  371. B<objsign>, B<reserved>, B<sslCA>, B<emailCA>, B<objCA>.
  372. =head1 ARBITRARY EXTENSIONS
  373. If an extension is not supported by the OpenSSL code then it must be encoded
  374. using the arbitrary extension format. It is also possible to use the arbitrary
  375. format for supported extensions. Extreme care should be taken to ensure that
  376. the data is formatted correctly for the given extension type.
  377. There are two ways to encode arbitrary extensions.
  378. The first way is to use the word ASN1 followed by the extension content
  379. using the same syntax as L<ASN1_generate_nconf(3)>.
  380. For example:
  381. [extensions]
  382. 1.2.3.4 = critical, ASN1:UTF8String:Some random data
  383. 1.2.3.4.1 = ASN1:SEQUENCE:seq_sect
  384. [seq_sect]
  385. field1 = UTF8:field1
  386. field2 = UTF8:field2
  387. It is also possible to use the word DER to include the raw encoded data in any
  388. extension.
  389. 1.2.3.4 = critical, DER:01:02:03:04
  390. 1.2.3.4.1 = DER:01020304
  391. The value following DER is a hex dump of the DER encoding of the extension
  392. Any extension can be placed in this form to override the default behaviour.
  393. For example:
  394. basicConstraints = critical, DER:00:01:02:03
  395. =head1 WARNINGS
  396. There is no guarantee that a specific implementation will process a given
  397. extension. It may therefore be sometimes possible to use certificates for
  398. purposes prohibited by their extensions because a specific application does
  399. not recognize or honour the values of the relevant extensions.
  400. The DER and ASN1 options should be used with caution. It is possible to create
  401. invalid extensions if they are not used carefully.
  402. =head1 SEE ALSO
  403. L<openssl-req(1)>, L<openssl-ca(1)>, L<openssl-x509(1)>,
  404. L<ASN1_generate_nconf(3)>
  405. =head1 COPYRIGHT
  406. Copyright 2004-2022 The OpenSSL Project Authors. All Rights Reserved.
  407. Licensed under the Apache License 2.0 (the "License"). You may not use
  408. this file except in compliance with the License. You can obtain a copy
  409. in the file LICENSE in the source distribution or at
  410. L<https://www.openssl.org/source/license.html>.
  411. =cut