xref: /openbsd/lib/libcrypto/man/x509v3.cnf.5 (revision 274d7c50)
1.\" $OpenBSD: x509v3.cnf.5,v 1.6 2019/06/06 01:06:59 schwarze Exp $
2.\" full merge up to:
3.\" OpenSSL man5/x509v3_config a41815f0 Mar 17 18:43:53 2017 -0700
4.\" selective merge up to: OpenSSL 36cf10cf Oct 4 02:11:08 2017 -0400
5.\"
6.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
7.\" Copyright (c) 2004, 2006, 2013, 2014, 2015, 2016 The OpenSSL Project.
8.\" All rights reserved.
9.\"
10.\" Redistribution and use in source and binary forms, with or without
11.\" modification, are permitted provided that the following conditions
12.\" are met:
13.\"
14.\" 1. Redistributions of source code must retain the above copyright
15.\"    notice, this list of conditions and the following disclaimer.
16.\"
17.\" 2. Redistributions in binary form must reproduce the above copyright
18.\"    notice, this list of conditions and the following disclaimer in
19.\"    the documentation and/or other materials provided with the
20.\"    distribution.
21.\"
22.\" 3. All advertising materials mentioning features or use of this
23.\"    software must display the following acknowledgment:
24.\"    "This product includes software developed by the OpenSSL Project
25.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
26.\"
27.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
28.\"    endorse or promote products derived from this software without
29.\"    prior written permission. For written permission, please contact
30.\"    openssl-core@openssl.org.
31.\"
32.\" 5. Products derived from this software may not be called "OpenSSL"
33.\"    nor may "OpenSSL" appear in their names without prior written
34.\"    permission of the OpenSSL Project.
35.\"
36.\" 6. Redistributions of any form whatsoever must retain the following
37.\"    acknowledgment:
38.\"    "This product includes software developed by the OpenSSL Project
39.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
40.\"
41.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
42.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
44.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
45.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
50.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
52.\" OF THE POSSIBILITY OF SUCH DAMAGE.
53.\"
54.Dd $Mdocdate: June 6 2019 $
55.Dt X509V3.CNF 5
56.Os
57.Sh NAME
58.Nm x509v3.cnf
59.Nd X.509 V3 certificate extension configuration format
60.Sh DESCRIPTION
61Several of the OpenSSL utilities can add extensions to a certificate or
62certificate request based on the contents of a configuration file.
63The file format is based on the
64.Xr openssl.cnf 5
65format.
66.Pp
67Typically the application will contain an option to point to an
68extension section.
69Each line of the extension section takes the form:
70.Pp
71.D1 Ar extension_name Ns = Ns Oo Cm critical , Oc Ar extension_options
72.Pp
73If
74.Cm critical
75is present, then the extension will be critical.
76.Pp
77The format of
78.Ar extension_options
79depends on the value of
80.Ar extension_name .
81.Pp
82There are four main types of extension: string extensions, multi-valued
83extensions, raw extensions, and arbitrary extensions.
84.Pp
85String extensions simply have a string which contains either the value
86itself or how it is obtained.
87For example:
88.Pp
89.Dl nsComment="This is a Comment"
90.Pp
91Multi-valued extensions have a short form and a long form.
92The short form is a list of names and values:
93.Pp
94.Dl basicConstraints=critical,CA:true,pathlen:1
95.Pp
96The long form allows the values to be placed in a separate section:
97.Bd -literal -offset indent
98basicConstraints=critical,@bs_section
99
100[bs_section]
101CA=true
102pathlen=1
103.Ed
104.Pp
105Both forms are equivalent.
106.Pp
107The syntax of raw extensions is governed by the extension code:
108it can for example contain data in multiple sections.
109The correct syntax to use is defined by the extension code itself:
110check out the certificate policies extension for an example.
111.Pp
112If an extension type is unsupported, then the arbitrary extension
113syntax must be used; see the
114.Sx ARBITRARY EXTENSIONS
115section for more details.
116.Sh STANDARD EXTENSIONS
117The following sections describe each supported extension in detail.
118.Ss Basic constraints
119This is a multi-valued extension which indicates whether a certificate
120is a CA certificate.
121The first (mandatory) name is
122.Ic CA
123followed by
124.Cm TRUE
125or
126.Cm FALSE .
127If
128.Ic CA
129is
130.Cm TRUE ,
131then an optional
132.Ic pathlen
133name followed by a non-negative value can be included.
134For example:
135.Bd -literal -offset indent
136basicConstraints=CA:TRUE
137basicConstraints=CA:FALSE
138basicConstraints=critical,CA:TRUE, pathlen:0
139.Ed
140.Pp
141A CA certificate must include the
142.Ic basicConstraints
143value with the
144.Ic CA
145field set to
146.Cm TRUE .
147An end user certificate must either set
148.Ic CA
149to
150.Cm FALSE
151or exclude the extension entirely.
152Some software may require the inclusion of
153.Ic basicConstraints
154with
155.Ic CA
156set to
157.Cm FALSE
158for end entity certificates.
159.Pp
160The
161.Ic pathlen
162parameter indicates the maximum number of CAs that can appear below
163this one in a chain.
164So if you have a CA with a
165.Ic pathlen
166of zero it can only be used to sign end user certificates and not
167further CAs.
168.Ss Key usage
169Key usage is a multi-valued extension consisting of a list of names of
170the permitted key usages.
171.Pp
172The supported names are:
173.Ic digitalSignature ,
174.Ic nonRepudiation ,
175.Ic keyEncipherment ,
176.Ic dataEncipherment ,
177.Ic keyAgreement ,
178.Ic keyCertSign ,
179.Ic cRLSign ,
180.Ic encipherOnly ,
181and
182.Ic decipherOnly .
183Examples:
184.Bd -literal -offset indent
185keyUsage=digitalSignature, nonRepudiation
186keyUsage=critical, keyCertSign
187.Ed
188.Ss Extended key usage
189This extensions consists of a list of usages indicating purposes for
190which the certificate public key can be used for.
191.Pp
192These can either be object short names or the dotted numerical form of OIDs.
193While any OID can be used, only certain values make sense.
194In particular the following PKIX, NS and MS values are meaningful:
195.Bl -column emailProtection
196.It Em value Ta Em meaning
197.It Ic serverAuth      Ta SSL/TLS web server authentication
198.It Ic clientAuth      Ta SSL/TLS web client authentication
199.It Ic codeSigning     Ta code signing
200.It Ic emailProtection Ta E-mail protection (S/MIME)
201.It Ic timeStamping    Ta trusted timestamping
202.It Ic OCSPSigning     Ta OCSP signing
203.It Ic ipsecIKE        Ta IPsec internet key exchange
204.It Ic msCodeInd       Ta Microsoft individual code signing (authenticode)
205.It Ic msCodeCom       Ta Microsoft commercial code signing (authenticode)
206.It Ic msCTLSign       Ta Microsoft trust list signing
207.It Ic msEFS           Ta Microsoft encrypted file system
208.El
209.Pp
210Examples:
211.Bd -literal -offset indent
212extendedKeyUsage=critical,codeSigning,1.2.3.4
213extendedKeyUsage=serverAuth,clientAuth
214.Ed
215.Ss Subject key identifier
216This is really a string extension and can take two possible values.
217Either the word
218.Cm hash
219which will automatically follow the guidelines in RFC 3280
220or a hex string giving the extension value to include.
221The use of the hex string is strongly discouraged.
222Example:
223.Pp
224.Dl subjectKeyIdentifier=hash
225.Ss Authority key identifier
226The authority key identifier extension permits two options,
227.Cm keyid
228and
229.Cm issuer :
230both can take the optional value
231.Cm always .
232.Pp
233If the
234.Cm keyid
235option is present, an attempt is made to copy the subject
236key identifier from the parent certificate.
237If the value
238.Cm always
239is present, then an error is returned if the option fails.
240.Pp
241The
242.Cm issuer
243option copies the issuer and serial number from the issuer certificate.
244This will only be done if the
245.Cm keyid
246option fails or is not included unless the
247.Cm always
248flag will always include the value.
249Example:
250.Pp
251.Dl authorityKeyIdentifier=keyid,issuer
252.Ss Subject alternative name
253The subject alternative name extension allows various literal values to
254be included in the configuration file.
255These include
256.Ic email
257(an email address),
258.Ic URI
259(a uniform resource indicator),
260.Ic DNS
261(a DNS domain name),
262.Ic RID
263(a registered ID: OBJECT IDENTIFIER),
264.Ic IP
265(an IP address),
266.Ic dirName
267(a distinguished name), and
268.Ic otherName .
269.Pp
270The
271.Ic email
272option can include a special
273.Cm copy
274value.
275This will automatically include any email addresses contained in the
276certificate subject name in the extension.
277.Pp
278The IP address used in the
279.Ic IP
280options can be in either IPv4 or IPv6 format.
281.Pp
282The value of
283.Ic dirName
284should point to a section containing the distinguished name to use as a
285set of name value pairs.
286Multi values AVAs can be formed by prefacing the name with a
287.Ql +
288character.
289.Pp
290.Ic otherName
291can include arbitrary data associated with an OID: the value should
292be the OID followed by a semicolon and the content in standard
293.Xr ASN1_generate_nconf 3
294format.
295Examples:
296.Bd -literal -offset 2n
297subjectAltName=email:copy,email:my@other.address,URI:http://my.url.here/
298subjectAltName=IP:192.168.7.1
299subjectAltName=IP:13::17
300subjectAltName=email:my@other.address,RID:1.2.3.4
301subjectAltName=otherName:1.2.3.4;UTF8:some other identifier
302
303subjectAltName=dirName:dir_sect
304
305[dir_sect]
306C=UK
307O=My Organization
308OU=My Unit
309CN=My Name
310.Ed
311.Ss Issuer alternative name
312The issuer alternative name option supports all the literal options of
313subject alternative name.
314It does not support the
315.Ic email : Ns Cm copy
316option because that would not make sense.
317It does support an additional
318.Ic issuer : Ns Cm copy
319option that will copy all the subject alternative name values from
320the issuer certificate (if possible).
321Example:
322.Pp
323.Dl issuerAltName = issuer:copy
324.Ss Authority info access
325The authority information access extension gives details about how to
326access certain information relating to the CA.
327Its syntax is
328.Ar accessOID ; location
329where
330.Ar location
331has the same syntax as subject alternative name (except that
332.Ic email : Ns Cm copy
333is not supported).
334.Ar accessOID
335can be any valid OID but only certain values are meaningful,
336for example
337.Cm OCSP
338and
339.Cm caIssuers .
340Example:
341.Bd -literal -offset indent
342authorityInfoAccess = OCSP;URI:http://ocsp.my.host/
343authorityInfoAccess = caIssuers;URI:http://my.ca/ca.html
344.Ed
345.Ss CRL distribution points
346This is a multi-valued extension whose options can be either in
347.Ar name : Ns Ar value
348pair form using the same form as subject alternative name or a
349single value representing a section name containing all the
350distribution point fields.
351.Pp
352For a
353.Ar name : Ns Ar value
354pair a new DistributionPoint with the fullName field set to the
355given value, both the cRLissuer and reasons fields are omitted in
356this case.
357.Pp
358In the single option case, the section indicated contains values
359for each field.
360In this section:
361.Pp
362If the name is
363.Ic fullname ,
364the value field should contain the full name of the distribution
365point in the same format as subject alternative name.
366.Pp
367If the name is
368.Ic relativename ,
369then the value field should contain a section name whose contents
370represent a DN fragment to be placed in this field.
371.Pp
372The name
373.Ic CRLIssuer ,
374if present, should contain a value for this field in subject
375alternative name format.
376.Pp
377If the name is
378.Ic reasons ,
379the value field should consist of a comma separated field containing
380the reasons.
381Valid reasons are:
382.Cm keyCompromise ,
383.Cm CACompromise ,
384.Cm affiliationChanged ,
385.Cm superseded ,
386.Cm cessationOfOperation ,
387.Cm certificateHold ,
388.Cm privilegeWithdrawn ,
389and
390.Cm AACompromise .
391.Pp
392Simple examples:
393.Bd -literal -offset indent
394crlDistributionPoints=URI:http://myhost.com/myca.crl
395crlDistributionPoints=URI:http://my.com/my.crl,URI:http://oth.com/my.crl
396.Ed
397.Pp
398Full distribution point example:
399.Bd -literal -offset indent
400crlDistributionPoints=crldp1_section
401
402[crldp1_section]
403fullname=URI:http://myhost.com/myca.crl
404CRLissuer=dirName:issuer_sect
405reasons=keyCompromise, CACompromise
406
407[issuer_sect]
408C=UK
409O=Organisation
410CN=Some Name
411.Ed
412.Ss Issuing distribution point
413This extension should only appear in CRLs.
414It is a multi-valued extension whose syntax is similar to the "section"
415pointed to by the CRL distribution points extension with a few
416differences.
417.Pp
418The names
419.Ic reasons
420and
421.Ic CRLissuer
422are not recognized.
423.Pp
424The name
425.Ic onlysomereasons
426is accepted, which sets this field.
427The value is in the same format as the CRL distribution point
428.Ic reasons
429field.
430.Pp
431The names
432.Ic onlyuser ,
433.Ic onlyCA ,
434.Ic onlyAA ,
435and
436.Ic indirectCRL
437are also accepted.
438The values should be a boolean values
439.Cm ( TRUE
440or
441.Cm FALSE )
442to indicate the value of the corresponding field.
443Example:
444.Bd -literal -offset indent
445issuingDistributionPoint=critical, @idp_section
446
447[idp_section]
448fullname=URI:http://myhost.com/myca.crl
449indirectCRL=TRUE
450onlysomereasons=keyCompromise, CACompromise
451
452[issuer_sect]
453C=UK
454O=Organisation
455CN=Some Name
456.Ed
457.Ss Certificate policies
458This is a raw extension.
459All the fields of this extension can be set by using the appropriate
460syntax.
461.Pp
462If you follow the PKIX recommendations and just use one OID, then you
463just include the value of that OID.
464Multiple OIDs can be set separated by commas, for example:
465.Pp
466.Dl certificatePolicies= 1.2.4.5, 1.1.3.4
467.Pp
468If you wish to include qualifiers, then the policy OID and qualifiers
469need to be specified in a separate section: this is done by using the
470.Pf @ Ar section
471syntax instead of a literal OID value.
472.Pp
473The section referred to must include the policy OID using the name
474.Ic policyIdentifier .
475.Ic CPSuri
476qualifiers can be included using the syntax:
477.Pp
478.D1 Ic CPS . Ns Ar nnn Ns = Ns Ar value
479.Pp
480.Ic userNotice
481qualifiers can be set using the syntax:
482.Pp
483.D1 Ic userNotice . Ns Ar nnn Ns =@ Ns Ar notice
484.Pp
485The value of the
486.Ic userNotice
487qualifier is specified in the relevant section.
488This section can include
489.Ic explicitText ,
490.Ic organization ,
491and
492.Ic noticeNumbers
493options.
494.Ic explicitText
495and
496.Ic organization
497are text strings,
498and
499.Ic noticeNumbers
500is a comma separated list of numbers.
501The
502.Ic organization
503and
504.Ic noticeNumbers
505options (if included) must
506.Em both
507be present.
508If you use the
509.Ic userNotice
510option with IE5 then you need the
511.Ic ia5org
512option at the top level to modify the encoding: otherwise it will
513not be interpreted properly.
514Example:
515.Bd -literal -offset indent
516certificatePolicies=ia5org,1.2.3.4,1.5.6.7.8,@polsect
517
518[polsect]
519policyIdentifier = 1.3.5.8
520CPS.1="http://my.host.name/"
521CPS.2="http://my.your.name/"
522userNotice.1=@notice
523
524[notice]
525explicitText="Explicit Text Here"
526organization="Organisation Name"
527noticeNumbers=1,2,3,4
528.Ed
529.Pp
530The
531.Ic ia5org
532option changes the type of the
533.Ic organization
534field.
535In RFC 2459, it can only be of type
536.Vt DisplayText .
537In RFC 3280,
538.Vt IA5String
539is also permissible.
540Some software (for example some versions of MSIE) may require
541.Ic ia5org .
542.Ss Policy constraints
543This is a multi-valued extension which consists of the names
544.Ic requireExplicitPolicy
545or
546.Ic inhibitPolicyMapping
547and a non-negative integer value.
548At least one component must be present.
549Example:
550.Pp
551.Dl policyConstraints = requireExplicitPolicy:3
552.Ss Inhibit any policy
553This is a string extension whose value must be a non-negative integer.
554Example:
555.Pp
556.Dl inhibitAnyPolicy = 2
557.Ss Name constraints
558The name constraints extension is a multi-valued extension.
559The name should begin with the word
560.Cm permitted
561or
562.Cm excluded ,
563followed by a semicolon.
564The rest of the name and the value follows the syntax of subjectAltName
565except
566.Ic email : Ns Cm copy
567is not supported and the
568.Ic IP
569form should consist of an IP addresses and subnet mask separated
570by a slash.
571Examples:
572.Bd -literal -offset indent
573nameConstraints=permitted;IP:192.168.0.0/255.255.0.0
574nameConstraints=permitted;email:.somedomain.com
575nameConstraints=excluded;email:.com
576.Ed
577.Ss OCSP no check
578The OCSP no check extension is a string extension,
579but its value is ignored.
580Example:
581.Pp
582.Dl noCheck = ignored
583.Ss TLS Feature (aka must staple)
584This is a multi-valued extension consisting of a list of TLS extension
585identifiers.
586Each identifier may be a number in the range from 0 to 65535 or a
587supported name.
588When a TLS client sends a listed extension, the TLS server is expected
589to include that extension in its reply.
590.Pp
591The supported names are:
592.Cm status_request
593and
594.Cm status_request_v2 .
595Example:
596.Pp
597.Dl tlsfeature = status_request
598.Sh DEPRECATED EXTENSIONS
599The following extensions are non-standard, Netscape specific and largely
600obsolete.
601Their use in new applications is discouraged.
602.Ss Netscape string extensions
603Netscape comment
604.Ic ( nsComment )
605is a string extension containing a comment which will be displayed when
606the certificate is viewed in some browsers.
607Example:
608.Pp
609.Dl nsComment = "Some Random Comment"
610.Pp
611Other supported extensions in this category are:
612.Ic nsBaseUrl ,
613.Ic nsRevocationUrl ,
614.Ic nsCaRevocationUrl ,
615.Ic nsRenewalUrl ,
616.Ic nsCaPolicyUrl ,
617and
618.Ic nsSslServerName .
619.Ss Netscape certificate type
620This is a multi-valued extensions which consists of a list of flags to
621be included.
622It was used to indicate the purposes for which a certificate could be
623used.
624The
625.Ic basicConstraints ,
626.Ic keyUsage ,
627and extended key usage extensions are now used instead.
628.Pp
629Acceptable values for
630.Ic nsCertType
631are:
632.Cm client ,
633.Cm server ,
634.Cm email ,
635.Cm objsign ,
636.Cm reserved ,
637.Cm sslCA ,
638.Cm emailCA ,
639.Cm objCA .
640.Sh ARBITRARY EXTENSIONS
641If an extension is not supported by the OpenSSL code, then it must
642be encoded using the arbitrary extension format.
643It is also possible to use the arbitrary format for supported
644extensions.
645Extreme care should be taken to ensure that the data is formatted
646correctly for the given extension type.
647.Pp
648There are two ways to encode arbitrary extensions.
649.Pp
650The first way is to use the word
651.Cm ASN1
652followed by the extension content using the same syntax as
653.Xr ASN1_generate_nconf 3 .
654For example:
655.Bd -literal -offset indent
6561.2.3.4=critical,ASN1:UTF8String:Some random data
6571.2.3.4=ASN1:SEQUENCE:seq_sect
658
659[seq_sect]
660field1 = UTF8:field1
661field2 = UTF8:field2
662.Ed
663.Pp
664It is also possible to use the word
665.Cm DER
666to include the raw encoded data in any extension.
667.Bd -literal -offset indent
6681.2.3.4=critical,DER:01:02:03:04
6691.2.3.4=DER:01020304
670.Ed
671.Pp
672The value following
673.Cm DER
674is a hex dump of the DER encoding of the extension.
675Any extension can be placed in this form to override the default behaviour.
676For example:
677.Pp
678.Dl basicConstraints=critical,DER:00:01:02:03
679.Sh FILES
680.Bl -tag -width /etc/ssl/x509v3.cnf -compact
681.It Pa /etc/ssl/x509v3.cnf
682standard configuration file
683.El
684.Sh SEE ALSO
685.Xr openssl 1 ,
686.Xr ASN1_generate_nconf 3 ,
687.Xr OPENSSL_config 3 ,
688.Xr openssl.cnf 5
689.Sh HISTORY
690X509v3 extension code was first added to OpenSSL 0.9.2.
691.Sh CAVEATS
692There is no guarantee that a specific implementation will process a
693given extension.
694It may therefore sometimes be possible to use certificates for purposes
695prohibited by their extensions because a specific application does not
696recognize or honour the values of the relevant extensions.
697.Pp
698The
699.Cm DER
700and
701.Cm ASN1
702options should be used with caution.
703It is possible to create totally invalid extensions if they are not used
704carefully.
705.Pp
706If an extension is multi-value and a field value must contain a comma,
707the long form must be used.
708Otherwise the comma would be misinterpreted as a field separator.
709For example,
710.Pp
711.Dl subjectAltName=URI:ldap://somehost.com/CN=foo,OU=bar
712.Pp
713will produce an error, but the following form is valid:
714.Bd -literal -offset indent
715subjectAltName=@subject_alt_section
716
717[subject_alt_section]
718subjectAltName=URI:ldap://somehost.com/CN=foo,OU=bar
719.Ed
720.Pp
721Due to the behaviour of the OpenSSL CONF library, the same field
722name can only occur once in a section.
723That means that
724.Bd -literal -offset indent
725subjectAltName=@alt_section
726
727[alt_section]
728email=steve@here
729email=steve@there
730.Ed
731.Pp
732will only use the last value.
733This can be worked around by using the form:
734.Bd -literal -offset indent
735[alt_section]
736email.1=steve@here
737email.2=steve@there
738.Ed
739