]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/usr.bin/openssl/man/x509.1
MFC: r359486
[FreeBSD/FreeBSD.git] / secure / usr.bin / openssl / man / x509.1
1 .\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.40)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is >0, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .nr rF 0
58 .if \n(.g .if rF .nr rF 1
59 .if (\n(rF:(\n(.g==0)) \{\
60 .    if \nF \{\
61 .        de IX
62 .        tm Index:\\$1\t\\n%\t"\\$2"
63 ..
64 .        if !\nF==2 \{\
65 .            nr % 0
66 .            nr F 2
67 .        \}
68 .    \}
69 .\}
70 .rr rF
71 .\"
72 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
73 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
74 .    \" fudge factors for nroff and troff
75 .if n \{\
76 .    ds #H 0
77 .    ds #V .8m
78 .    ds #F .3m
79 .    ds #[ \f1
80 .    ds #] \fP
81 .\}
82 .if t \{\
83 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
84 .    ds #V .6m
85 .    ds #F 0
86 .    ds #[ \&
87 .    ds #] \&
88 .\}
89 .    \" simple accents for nroff and troff
90 .if n \{\
91 .    ds ' \&
92 .    ds ` \&
93 .    ds ^ \&
94 .    ds , \&
95 .    ds ~ ~
96 .    ds /
97 .\}
98 .if t \{\
99 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
100 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
101 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
102 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
103 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
104 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
105 .\}
106 .    \" troff and (daisy-wheel) nroff accents
107 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
108 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
109 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
110 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
111 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
112 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
113 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
114 .ds ae a\h'-(\w'a'u*4/10)'e
115 .ds Ae A\h'-(\w'A'u*4/10)'E
116 .    \" corrections for vroff
117 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
118 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
119 .    \" for low resolution devices (crt and lpr)
120 .if \n(.H>23 .if \n(.V>19 \
121 \{\
122 .    ds : e
123 .    ds 8 ss
124 .    ds o a
125 .    ds d- d\h'-1'\(ga
126 .    ds D- D\h'-1'\(hy
127 .    ds th \o'bp'
128 .    ds Th \o'LP'
129 .    ds ae ae
130 .    ds Ae AE
131 .\}
132 .rm #[ #] #H #V #F C
133 .\" ========================================================================
134 .\"
135 .IX Title "X509 1"
136 .TH X509 1 "2020-03-31" "1.1.1f" "OpenSSL"
137 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
138 .\" way too many mistakes in technical documents.
139 .if n .ad l
140 .nh
141 .SH "NAME"
142 openssl\-x509, x509 \- Certificate display and signing utility
143 .SH "SYNOPSIS"
144 .IX Header "SYNOPSIS"
145 \&\fBopenssl\fR \fBx509\fR
146 [\fB\-help\fR]
147 [\fB\-inform DER|PEM\fR]
148 [\fB\-outform DER|PEM\fR]
149 [\fB\-keyform DER|PEM|ENGINE\fR]
150 [\fB\-CAform DER|PEM\fR]
151 [\fB\-CAkeyform DER|PEM\fR]
152 [\fB\-in filename\fR]
153 [\fB\-out filename\fR]
154 [\fB\-serial\fR]
155 [\fB\-hash\fR]
156 [\fB\-subject_hash\fR]
157 [\fB\-issuer_hash\fR]
158 [\fB\-ocspid\fR]
159 [\fB\-subject\fR]
160 [\fB\-issuer\fR]
161 [\fB\-nameopt option\fR]
162 [\fB\-email\fR]
163 [\fB\-ocsp_uri\fR]
164 [\fB\-startdate\fR]
165 [\fB\-enddate\fR]
166 [\fB\-purpose\fR]
167 [\fB\-dates\fR]
168 [\fB\-checkend num\fR]
169 [\fB\-modulus\fR]
170 [\fB\-pubkey\fR]
171 [\fB\-fingerprint\fR]
172 [\fB\-alias\fR]
173 [\fB\-noout\fR]
174 [\fB\-trustout\fR]
175 [\fB\-clrtrust\fR]
176 [\fB\-clrreject\fR]
177 [\fB\-addtrust arg\fR]
178 [\fB\-addreject arg\fR]
179 [\fB\-setalias arg\fR]
180 [\fB\-days arg\fR]
181 [\fB\-set_serial n\fR]
182 [\fB\-signkey arg\fR]
183 [\fB\-passin arg\fR]
184 [\fB\-x509toreq\fR]
185 [\fB\-req\fR]
186 [\fB\-CA filename\fR]
187 [\fB\-CAkey filename\fR]
188 [\fB\-CAcreateserial\fR]
189 [\fB\-CAserial filename\fR]
190 [\fB\-force_pubkey key\fR]
191 [\fB\-text\fR]
192 [\fB\-ext extensions\fR]
193 [\fB\-certopt option\fR]
194 [\fB\-C\fR]
195 [\fB\-\f(BIdigest\fB\fR]
196 [\fB\-clrext\fR]
197 [\fB\-extfile filename\fR]
198 [\fB\-extensions section\fR]
199 [\fB\-sigopt nm:v\fR]
200 [\fB\-rand file...\fR]
201 [\fB\-writerand file\fR]
202 [\fB\-engine id\fR]
203 [\fB\-preserve_dates\fR]
204 .SH "DESCRIPTION"
205 .IX Header "DESCRIPTION"
206 The \fBx509\fR command is a multi purpose certificate utility. It can be
207 used to display certificate information, convert certificates to
208 various forms, sign certificate requests like a \*(L"mini \s-1CA\*(R"\s0 or edit
209 certificate trust settings.
210 .PP
211 Since there are a large number of options they will split up into
212 various sections.
213 .SH "OPTIONS"
214 .IX Header "OPTIONS"
215 .SS "Input, Output, and General Purpose Options"
216 .IX Subsection "Input, Output, and General Purpose Options"
217 .IP "\fB\-help\fR" 4
218 .IX Item "-help"
219 Print out a usage message.
220 .IP "\fB\-inform DER|PEM\fR" 4
221 .IX Item "-inform DER|PEM"
222 This specifies the input format normally the command will expect an X509
223 certificate but this can change if other options such as \fB\-req\fR are
224 present. The \s-1DER\s0 format is the \s-1DER\s0 encoding of the certificate and \s-1PEM\s0
225 is the base64 encoding of the \s-1DER\s0 encoding with header and footer lines
226 added. The default format is \s-1PEM.\s0
227 .IP "\fB\-outform DER|PEM\fR" 4
228 .IX Item "-outform DER|PEM"
229 This specifies the output format, the options have the same meaning and default
230 as the \fB\-inform\fR option.
231 .IP "\fB\-in filename\fR" 4
232 .IX Item "-in filename"
233 This specifies the input filename to read a certificate from or standard input
234 if this option is not specified.
235 .IP "\fB\-out filename\fR" 4
236 .IX Item "-out filename"
237 This specifies the output filename to write to or standard output by
238 default.
239 .IP "\fB\-\f(BIdigest\fB\fR" 4
240 .IX Item "-digest"
241 The digest to use.
242 This affects any signing or display option that uses a message
243 digest, such as the \fB\-fingerprint\fR, \fB\-signkey\fR and \fB\-CA\fR options.
244 Any digest supported by the OpenSSL \fBdgst\fR command can be used.
245 If not specified then \s-1SHA1\s0 is used with \fB\-fingerprint\fR or
246 the default digest for the signing algorithm is used, typically \s-1SHA256.\s0
247 .IP "\fB\-rand file...\fR" 4
248 .IX Item "-rand file..."
249 A file or files containing random data used to seed the random number
250 generator.
251 Multiple files can be specified separated by an OS-dependent character.
252 The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for
253 all others.
254 .IP "[\fB\-writerand file\fR]" 4
255 .IX Item "[-writerand file]"
256 Writes random data to the specified \fIfile\fR upon exit.
257 This can be used with a subsequent \fB\-rand\fR flag.
258 .IP "\fB\-engine id\fR" 4
259 .IX Item "-engine id"
260 Specifying an engine (by its unique \fBid\fR string) will cause \fBx509\fR
261 to attempt to obtain a functional reference to the specified engine,
262 thus initialising it if needed. The engine will then be set as the default
263 for all available algorithms.
264 .IP "\fB\-preserve_dates\fR" 4
265 .IX Item "-preserve_dates"
266 When signing a certificate, preserve the \*(L"notBefore\*(R" and \*(L"notAfter\*(R" dates instead
267 of adjusting them to current time and duration. Cannot be used with the \fB\-days\fR option.
268 .SS "Display Options"
269 .IX Subsection "Display Options"
270 Note: the \fB\-alias\fR and \fB\-purpose\fR options are also display options
271 but are described in the \fB\s-1TRUST SETTINGS\s0\fR section.
272 .IP "\fB\-text\fR" 4
273 .IX Item "-text"
274 Prints out the certificate in text form. Full details are output including the
275 public key, signature algorithms, issuer and subject names, serial number
276 any extensions present and any trust settings.
277 .IP "\fB\-ext extensions\fR" 4
278 .IX Item "-ext extensions"
279 Prints out the certificate extensions in text form. Extensions are specified
280 with a comma separated string, e.g., \*(L"subjectAltName,subjectKeyIdentifier\*(R".
281 See the \fBx509v3_config\fR\|(5) manual page for the extension names.
282 .IP "\fB\-certopt option\fR" 4
283 .IX Item "-certopt option"
284 Customise the output format used with \fB\-text\fR. The \fBoption\fR argument
285 can be a single option or multiple options separated by commas. The
286 \&\fB\-certopt\fR switch may be also be used more than once to set multiple
287 options. See the \fB\s-1TEXT OPTIONS\s0\fR section for more information.
288 .IP "\fB\-noout\fR" 4
289 .IX Item "-noout"
290 This option prevents output of the encoded version of the certificate.
291 .IP "\fB\-pubkey\fR" 4
292 .IX Item "-pubkey"
293 Outputs the certificate's SubjectPublicKeyInfo block in \s-1PEM\s0 format.
294 .IP "\fB\-modulus\fR" 4
295 .IX Item "-modulus"
296 This option prints out the value of the modulus of the public key
297 contained in the certificate.
298 .IP "\fB\-serial\fR" 4
299 .IX Item "-serial"
300 Outputs the certificate serial number.
301 .IP "\fB\-subject_hash\fR" 4
302 .IX Item "-subject_hash"
303 Outputs the \*(L"hash\*(R" of the certificate subject name. This is used in OpenSSL to
304 form an index to allow certificates in a directory to be looked up by subject
305 name.
306 .IP "\fB\-issuer_hash\fR" 4
307 .IX Item "-issuer_hash"
308 Outputs the \*(L"hash\*(R" of the certificate issuer name.
309 .IP "\fB\-ocspid\fR" 4
310 .IX Item "-ocspid"
311 Outputs the \s-1OCSP\s0 hash values for the subject name and public key.
312 .IP "\fB\-hash\fR" 4
313 .IX Item "-hash"
314 Synonym for \*(L"\-subject_hash\*(R" for backward compatibility reasons.
315 .IP "\fB\-subject_hash_old\fR" 4
316 .IX Item "-subject_hash_old"
317 Outputs the \*(L"hash\*(R" of the certificate subject name using the older algorithm
318 as used by OpenSSL before version 1.0.0.
319 .IP "\fB\-issuer_hash_old\fR" 4
320 .IX Item "-issuer_hash_old"
321 Outputs the \*(L"hash\*(R" of the certificate issuer name using the older algorithm
322 as used by OpenSSL before version 1.0.0.
323 .IP "\fB\-subject\fR" 4
324 .IX Item "-subject"
325 Outputs the subject name.
326 .IP "\fB\-issuer\fR" 4
327 .IX Item "-issuer"
328 Outputs the issuer name.
329 .IP "\fB\-nameopt option\fR" 4
330 .IX Item "-nameopt option"
331 Option which determines how the subject or issuer names are displayed. The
332 \&\fBoption\fR argument can be a single option or multiple options separated by
333 commas.  Alternatively the \fB\-nameopt\fR switch may be used more than once to
334 set multiple options. See the \fB\s-1NAME OPTIONS\s0\fR section for more information.
335 .IP "\fB\-email\fR" 4
336 .IX Item "-email"
337 Outputs the email address(es) if any.
338 .IP "\fB\-ocsp_uri\fR" 4
339 .IX Item "-ocsp_uri"
340 Outputs the \s-1OCSP\s0 responder address(es) if any.
341 .IP "\fB\-startdate\fR" 4
342 .IX Item "-startdate"
343 Prints out the start date of the certificate, that is the notBefore date.
344 .IP "\fB\-enddate\fR" 4
345 .IX Item "-enddate"
346 Prints out the expiry date of the certificate, that is the notAfter date.
347 .IP "\fB\-dates\fR" 4
348 .IX Item "-dates"
349 Prints out the start and expiry dates of a certificate.
350 .IP "\fB\-checkend arg\fR" 4
351 .IX Item "-checkend arg"
352 Checks if the certificate expires within the next \fBarg\fR seconds and exits
353 non-zero if yes it will expire or zero if not.
354 .IP "\fB\-fingerprint\fR" 4
355 .IX Item "-fingerprint"
356 Calculates and outputs the digest of the \s-1DER\s0 encoded version of the entire
357 certificate (see digest options).
358 This is commonly called a \*(L"fingerprint\*(R". Because of the nature of message
359 digests, the fingerprint of a certificate is unique to that certificate and
360 two certificates with the same fingerprint can be considered to be the same.
361 .IP "\fB\-C\fR" 4
362 .IX Item "-C"
363 This outputs the certificate in the form of a C source file.
364 .SS "Trust Settings"
365 .IX Subsection "Trust Settings"
366 A \fBtrusted certificate\fR is an ordinary certificate which has several
367 additional pieces of information attached to it such as the permitted
368 and prohibited uses of the certificate and an \*(L"alias\*(R".
369 .PP
370 Normally when a certificate is being verified at least one certificate
371 must be \*(L"trusted\*(R". By default a trusted certificate must be stored
372 locally and must be a root \s-1CA:\s0 any certificate chain ending in this \s-1CA\s0
373 is then usable for any purpose.
374 .PP
375 Trust settings currently are only used with a root \s-1CA.\s0 They allow a finer
376 control over the purposes the root \s-1CA\s0 can be used for. For example a \s-1CA\s0
377 may be trusted for \s-1SSL\s0 client but not \s-1SSL\s0 server use.
378 .PP
379 See the description of the \fBverify\fR utility for more information on the
380 meaning of trust settings.
381 .PP
382 Future versions of OpenSSL will recognize trust settings on any
383 certificate: not just root CAs.
384 .IP "\fB\-trustout\fR" 4
385 .IX Item "-trustout"
386 This causes \fBx509\fR to output a \fBtrusted\fR certificate. An ordinary
387 or trusted certificate can be input but by default an ordinary
388 certificate is output and any trust settings are discarded. With the
389 \&\fB\-trustout\fR option a trusted certificate is output. A trusted
390 certificate is automatically output if any trust settings are modified.
391 .IP "\fB\-setalias arg\fR" 4
392 .IX Item "-setalias arg"
393 Sets the alias of the certificate. This will allow the certificate
394 to be referred to using a nickname for example \*(L"Steve's Certificate\*(R".
395 .IP "\fB\-alias\fR" 4
396 .IX Item "-alias"
397 Outputs the certificate alias, if any.
398 .IP "\fB\-clrtrust\fR" 4
399 .IX Item "-clrtrust"
400 Clears all the permitted or trusted uses of the certificate.
401 .IP "\fB\-clrreject\fR" 4
402 .IX Item "-clrreject"
403 Clears all the prohibited or rejected uses of the certificate.
404 .IP "\fB\-addtrust arg\fR" 4
405 .IX Item "-addtrust arg"
406 Adds a trusted certificate use.
407 Any object name can be used here but currently only \fBclientAuth\fR (\s-1SSL\s0 client
408 use), \fBserverAuth\fR (\s-1SSL\s0 server use), \fBemailProtection\fR (S/MIME email) and
409 \&\fBanyExtendedKeyUsage\fR are used.
410 As of OpenSSL 1.1.0, the last of these blocks all purposes when rejected or
411 enables all purposes when trusted.
412 Other OpenSSL applications may define additional uses.
413 .IP "\fB\-addreject arg\fR" 4
414 .IX Item "-addreject arg"
415 Adds a prohibited use. It accepts the same values as the \fB\-addtrust\fR
416 option.
417 .IP "\fB\-purpose\fR" 4
418 .IX Item "-purpose"
419 This option performs tests on the certificate extensions and outputs
420 the results. For a more complete description see the \fB\s-1CERTIFICATE
421 EXTENSIONS\s0\fR section.
422 .SS "Signing Options"
423 .IX Subsection "Signing Options"
424 The \fBx509\fR utility can be used to sign certificates and requests: it
425 can thus behave like a \*(L"mini \s-1CA\*(R".\s0
426 .IP "\fB\-signkey arg\fR" 4
427 .IX Item "-signkey arg"
428 This option causes the input file to be self signed using the supplied
429 private key or engine. The private key's format is specified with the
430 \&\fB\-keyform\fR option.
431 .Sp
432 If the input file is a certificate it sets the issuer name to the
433 subject name (i.e.  makes it self signed) changes the public key to the
434 supplied value and changes the start and end dates. The start date is
435 set to the current time and the end date is set to a value determined
436 by the \fB\-days\fR option. Any certificate extensions are retained unless
437 the \fB\-clrext\fR option is supplied; this includes, for example, any existing
438 key identifier extensions.
439 .Sp
440 If the input is a certificate request then a self signed certificate
441 is created using the supplied private key using the subject name in
442 the request.
443 .IP "\fB\-sigopt nm:v\fR" 4
444 .IX Item "-sigopt nm:v"
445 Pass options to the signature algorithm during sign or verify operations.
446 Names and values of these options are algorithm-specific.
447 .IP "\fB\-passin arg\fR" 4
448 .IX Item "-passin arg"
449 The key password source. For more information about the format of \fBarg\fR
450 see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fBopenssl\fR\|(1).
451 .IP "\fB\-clrext\fR" 4
452 .IX Item "-clrext"
453 Delete any extensions from a certificate. This option is used when a
454 certificate is being created from another certificate (for example with
455 the \fB\-signkey\fR or the \fB\-CA\fR options). Normally all extensions are
456 retained.
457 .IP "\fB\-keyform PEM|DER|ENGINE\fR" 4
458 .IX Item "-keyform PEM|DER|ENGINE"
459 Specifies the format (\s-1DER\s0 or \s-1PEM\s0) of the private key file used in the
460 \&\fB\-signkey\fR option.
461 .IP "\fB\-days arg\fR" 4
462 .IX Item "-days arg"
463 Specifies the number of days to make a certificate valid for. The default
464 is 30 days. Cannot be used with the \fB\-preserve_dates\fR option.
465 .IP "\fB\-x509toreq\fR" 4
466 .IX Item "-x509toreq"
467 Converts a certificate into a certificate request. The \fB\-signkey\fR option
468 is used to pass the required private key.
469 .IP "\fB\-req\fR" 4
470 .IX Item "-req"
471 By default a certificate is expected on input. With this option a
472 certificate request is expected instead.
473 .IP "\fB\-set_serial n\fR" 4
474 .IX Item "-set_serial n"
475 Specifies the serial number to use. This option can be used with either
476 the \fB\-signkey\fR or \fB\-CA\fR options. If used in conjunction with the \fB\-CA\fR
477 option the serial number file (as specified by the \fB\-CAserial\fR or
478 \&\fB\-CAcreateserial\fR options) is not used.
479 .Sp
480 The serial number can be decimal or hex (if preceded by \fB0x\fR).
481 .IP "\fB\-CA filename\fR" 4
482 .IX Item "-CA filename"
483 Specifies the \s-1CA\s0 certificate to be used for signing. When this option is
484 present \fBx509\fR behaves like a \*(L"mini \s-1CA\*(R".\s0 The input file is signed by this
485 \&\s-1CA\s0 using this option: that is its issuer name is set to the subject name
486 of the \s-1CA\s0 and it is digitally signed using the CAs private key.
487 .Sp
488 This option is normally combined with the \fB\-req\fR option. Without the
489 \&\fB\-req\fR option the input is a certificate which must be self signed.
490 .IP "\fB\-CAkey filename\fR" 4
491 .IX Item "-CAkey filename"
492 Sets the \s-1CA\s0 private key to sign a certificate with. If this option is
493 not specified then it is assumed that the \s-1CA\s0 private key is present in
494 the \s-1CA\s0 certificate file.
495 .IP "\fB\-CAserial filename\fR" 4
496 .IX Item "-CAserial filename"
497 Sets the \s-1CA\s0 serial number file to use.
498 .Sp
499 When the \fB\-CA\fR option is used to sign a certificate it uses a serial
500 number specified in a file. This file consists of one line containing
501 an even number of hex digits with the serial number to use. After each
502 use the serial number is incremented and written out to the file again.
503 .Sp
504 The default filename consists of the \s-1CA\s0 certificate file base name with
505 \&\*(L".srl\*(R" appended. For example if the \s-1CA\s0 certificate file is called
506 \&\*(L"mycacert.pem\*(R" it expects to find a serial number file called \*(L"mycacert.srl\*(R".
507 .IP "\fB\-CAcreateserial\fR" 4
508 .IX Item "-CAcreateserial"
509 With this option the \s-1CA\s0 serial number file is created if it does not exist:
510 it will contain the serial number \*(L"02\*(R" and the certificate being signed will
511 have the 1 as its serial number. If the \fB\-CA\fR option is specified
512 and the serial number file does not exist a random number is generated;
513 this is the recommended practice.
514 .IP "\fB\-extfile filename\fR" 4
515 .IX Item "-extfile filename"
516 File containing certificate extensions to use. If not specified then
517 no extensions are added to the certificate.
518 .IP "\fB\-extensions section\fR" 4
519 .IX Item "-extensions section"
520 The section to add certificate extensions from. If this option is not
521 specified then the extensions should either be contained in the unnamed
522 (default) section or the default section should contain a variable called
523 \&\*(L"extensions\*(R" which contains the section to use. See the
524 \&\fBx509v3_config\fR\|(5) manual page for details of the
525 extension section format.
526 .IP "\fB\-force_pubkey key\fR" 4
527 .IX Item "-force_pubkey key"
528 When a certificate is created set its public key to \fBkey\fR instead of the
529 key in the certificate or certificate request. This option is useful for
530 creating certificates where the algorithm can't normally sign requests, for
531 example \s-1DH.\s0
532 .Sp
533 The format or \fBkey\fR can be specified using the \fB\-keyform\fR option.
534 .SS "Name Options"
535 .IX Subsection "Name Options"
536 The \fBnameopt\fR command line switch determines how the subject and issuer
537 names are displayed. If no \fBnameopt\fR switch is present the default \*(L"oneline\*(R"
538 format is used which is compatible with previous versions of OpenSSL.
539 Each option is described in detail below, all options can be preceded by
540 a \fB\-\fR to turn the option off. Only the first four will normally be used.
541 .IP "\fBcompat\fR" 4
542 .IX Item "compat"
543 Use the old format.
544 .IP "\fB\s-1RFC2253\s0\fR" 4
545 .IX Item "RFC2253"
546 Displays names compatible with \s-1RFC2253\s0 equivalent to \fBesc_2253\fR, \fBesc_ctrl\fR,
547 \&\fBesc_msb\fR, \fButf8\fR, \fBdump_nostr\fR, \fBdump_unknown\fR, \fBdump_der\fR,
548 \&\fBsep_comma_plus\fR, \fBdn_rev\fR and \fBsname\fR.
549 .IP "\fBoneline\fR" 4
550 .IX Item "oneline"
551 A oneline format which is more readable than \s-1RFC2253.\s0 It is equivalent to
552 specifying the  \fBesc_2253\fR, \fBesc_ctrl\fR, \fBesc_msb\fR, \fButf8\fR, \fBdump_nostr\fR,
553 \&\fBdump_der\fR, \fBuse_quote\fR, \fBsep_comma_plus_space\fR, \fBspace_eq\fR and \fBsname\fR
554 options.  This is the \fIdefault\fR of no name options are given explicitly.
555 .IP "\fBmultiline\fR" 4
556 .IX Item "multiline"
557 A multiline format. It is equivalent \fBesc_ctrl\fR, \fBesc_msb\fR, \fBsep_multiline\fR,
558 \&\fBspace_eq\fR, \fBlname\fR and \fBalign\fR.
559 .IP "\fBesc_2253\fR" 4
560 .IX Item "esc_2253"
561 Escape the \*(L"special\*(R" characters required by \s-1RFC2253\s0 in a field. That is
562 \&\fB,+"<>;\fR. Additionally \fB#\fR is escaped at the beginning of a string
563 and a space character at the beginning or end of a string.
564 .IP "\fBesc_2254\fR" 4
565 .IX Item "esc_2254"
566 Escape the \*(L"special\*(R" characters required by \s-1RFC2254\s0 in a field. That is
567 the \fB\s-1NUL\s0\fR character as well as and \fB()*\fR.
568 .IP "\fBesc_ctrl\fR" 4
569 .IX Item "esc_ctrl"
570 Escape control characters. That is those with \s-1ASCII\s0 values less than
571 0x20 (space) and the delete (0x7f) character. They are escaped using the
572 \&\s-1RFC2253\s0 \eXX notation (where \s-1XX\s0 are two hex digits representing the
573 character value).
574 .IP "\fBesc_msb\fR" 4
575 .IX Item "esc_msb"
576 Escape characters with the \s-1MSB\s0 set, that is with \s-1ASCII\s0 values larger than
577 127.
578 .IP "\fBuse_quote\fR" 4
579 .IX Item "use_quote"
580 Escapes some characters by surrounding the whole string with \fB"\fR characters,
581 without the option all escaping is done with the \fB\e\fR character.
582 .IP "\fButf8\fR" 4
583 .IX Item "utf8"
584 Convert all strings to \s-1UTF8\s0 format first. This is required by \s-1RFC2253.\s0 If
585 you are lucky enough to have a \s-1UTF8\s0 compatible terminal then the use
586 of this option (and \fBnot\fR setting \fBesc_msb\fR) may result in the correct
587 display of multibyte (international) characters. Is this option is not
588 present then multibyte characters larger than 0xff will be represented
589 using the format \eUXXXX for 16 bits and \eWXXXXXXXX for 32 bits.
590 Also if this option is off any UTF8Strings will be converted to their
591 character form first.
592 .IP "\fBignore_type\fR" 4
593 .IX Item "ignore_type"
594 This option does not attempt to interpret multibyte characters in any
595 way. That is their content octets are merely dumped as though one octet
596 represents each character. This is useful for diagnostic purposes but
597 will result in rather odd looking output.
598 .IP "\fBshow_type\fR" 4
599 .IX Item "show_type"
600 Show the type of the \s-1ASN1\s0 character string. The type precedes the
601 field contents. For example \*(L"\s-1BMPSTRING:\s0 Hello World\*(R".
602 .IP "\fBdump_der\fR" 4
603 .IX Item "dump_der"
604 When this option is set any fields that need to be hexdumped will
605 be dumped using the \s-1DER\s0 encoding of the field. Otherwise just the
606 content octets will be displayed. Both options use the \s-1RFC2253\s0
607 \&\fB#XXXX...\fR format.
608 .IP "\fBdump_nostr\fR" 4
609 .IX Item "dump_nostr"
610 Dump non character string types (for example \s-1OCTET STRING\s0) if this
611 option is not set then non character string types will be displayed
612 as though each content octet represents a single character.
613 .IP "\fBdump_all\fR" 4
614 .IX Item "dump_all"
615 Dump all fields. This option when used with \fBdump_der\fR allows the
616 \&\s-1DER\s0 encoding of the structure to be unambiguously determined.
617 .IP "\fBdump_unknown\fR" 4
618 .IX Item "dump_unknown"
619 Dump any field whose \s-1OID\s0 is not recognised by OpenSSL.
620 .IP "\fBsep_comma_plus\fR, \fBsep_comma_plus_space\fR, \fBsep_semi_plus_space\fR, \fBsep_multiline\fR" 4
621 .IX Item "sep_comma_plus, sep_comma_plus_space, sep_semi_plus_space, sep_multiline"
622 These options determine the field separators. The first character is
623 between RDNs and the second between multiple AVAs (multiple AVAs are
624 very rare and their use is discouraged). The options ending in
625 \&\*(L"space\*(R" additionally place a space after the separator to make it
626 more readable. The \fBsep_multiline\fR uses a linefeed character for
627 the \s-1RDN\s0 separator and a spaced \fB+\fR for the \s-1AVA\s0 separator. It also
628 indents the fields by four characters. If no field separator is specified
629 then \fBsep_comma_plus_space\fR is used by default.
630 .IP "\fBdn_rev\fR" 4
631 .IX Item "dn_rev"
632 Reverse the fields of the \s-1DN.\s0 This is required by \s-1RFC2253.\s0 As a side
633 effect this also reverses the order of multiple AVAs but this is
634 permissible.
635 .IP "\fBnofname\fR, \fBsname\fR, \fBlname\fR, \fBoid\fR" 4
636 .IX Item "nofname, sname, lname, oid"
637 These options alter how the field name is displayed. \fBnofname\fR does
638 not display the field at all. \fBsname\fR uses the \*(L"short name\*(R" form
639 (\s-1CN\s0 for commonName for example). \fBlname\fR uses the long form.
640 \&\fBoid\fR represents the \s-1OID\s0 in numerical form and is useful for
641 diagnostic purpose.
642 .IP "\fBalign\fR" 4
643 .IX Item "align"
644 Align field values for a more readable output. Only usable with
645 \&\fBsep_multiline\fR.
646 .IP "\fBspace_eq\fR" 4
647 .IX Item "space_eq"
648 Places spaces round the \fB=\fR character which follows the field
649 name.
650 .SS "Text Options"
651 .IX Subsection "Text Options"
652 As well as customising the name output format, it is also possible to
653 customise the actual fields printed using the \fBcertopt\fR options when
654 the \fBtext\fR option is present. The default behaviour is to print all fields.
655 .IP "\fBcompatible\fR" 4
656 .IX Item "compatible"
657 Use the old format. This is equivalent to specifying no output options at all.
658 .IP "\fBno_header\fR" 4
659 .IX Item "no_header"
660 Don't print header information: that is the lines saying \*(L"Certificate\*(R"
661 and \*(L"Data\*(R".
662 .IP "\fBno_version\fR" 4
663 .IX Item "no_version"
664 Don't print out the version number.
665 .IP "\fBno_serial\fR" 4
666 .IX Item "no_serial"
667 Don't print out the serial number.
668 .IP "\fBno_signame\fR" 4
669 .IX Item "no_signame"
670 Don't print out the signature algorithm used.
671 .IP "\fBno_validity\fR" 4
672 .IX Item "no_validity"
673 Don't print the validity, that is the \fBnotBefore\fR and \fBnotAfter\fR fields.
674 .IP "\fBno_subject\fR" 4
675 .IX Item "no_subject"
676 Don't print out the subject name.
677 .IP "\fBno_issuer\fR" 4
678 .IX Item "no_issuer"
679 Don't print out the issuer name.
680 .IP "\fBno_pubkey\fR" 4
681 .IX Item "no_pubkey"
682 Don't print out the public key.
683 .IP "\fBno_sigdump\fR" 4
684 .IX Item "no_sigdump"
685 Don't give a hexadecimal dump of the certificate signature.
686 .IP "\fBno_aux\fR" 4
687 .IX Item "no_aux"
688 Don't print out certificate trust information.
689 .IP "\fBno_extensions\fR" 4
690 .IX Item "no_extensions"
691 Don't print out any X509V3 extensions.
692 .IP "\fBext_default\fR" 4
693 .IX Item "ext_default"
694 Retain default extension behaviour: attempt to print out unsupported
695 certificate extensions.
696 .IP "\fBext_error\fR" 4
697 .IX Item "ext_error"
698 Print an error message for unsupported certificate extensions.
699 .IP "\fBext_parse\fR" 4
700 .IX Item "ext_parse"
701 \&\s-1ASN1\s0 parse unsupported extensions.
702 .IP "\fBext_dump\fR" 4
703 .IX Item "ext_dump"
704 Hex dump unsupported extensions.
705 .IP "\fBca_default\fR" 4
706 .IX Item "ca_default"
707 The value used by the \fBca\fR utility, equivalent to \fBno_issuer\fR, \fBno_pubkey\fR,
708 \&\fBno_header\fR, and \fBno_version\fR.
709 .SH "EXAMPLES"
710 .IX Header "EXAMPLES"
711 Note: in these examples the '\e' means the example should be all on one
712 line.
713 .PP
714 Display the contents of a certificate:
715 .PP
716 .Vb 1
717 \& openssl x509 \-in cert.pem \-noout \-text
718 .Ve
719 .PP
720 Display the \*(L"Subject Alternative Name\*(R" extension of a certificate:
721 .PP
722 .Vb 1
723 \& openssl x509 \-in cert.pem \-noout \-ext subjectAltName
724 .Ve
725 .PP
726 Display more extensions of a certificate:
727 .PP
728 .Vb 1
729 \& openssl x509 \-in cert.pem \-noout \-ext subjectAltName,nsCertType
730 .Ve
731 .PP
732 Display the certificate serial number:
733 .PP
734 .Vb 1
735 \& openssl x509 \-in cert.pem \-noout \-serial
736 .Ve
737 .PP
738 Display the certificate subject name:
739 .PP
740 .Vb 1
741 \& openssl x509 \-in cert.pem \-noout \-subject
742 .Ve
743 .PP
744 Display the certificate subject name in \s-1RFC2253\s0 form:
745 .PP
746 .Vb 1
747 \& openssl x509 \-in cert.pem \-noout \-subject \-nameopt RFC2253
748 .Ve
749 .PP
750 Display the certificate subject name in oneline form on a terminal
751 supporting \s-1UTF8:\s0
752 .PP
753 .Vb 1
754 \& openssl x509 \-in cert.pem \-noout \-subject \-nameopt oneline,\-esc_msb
755 .Ve
756 .PP
757 Display the certificate \s-1SHA1\s0 fingerprint:
758 .PP
759 .Vb 1
760 \& openssl x509 \-sha1 \-in cert.pem \-noout \-fingerprint
761 .Ve
762 .PP
763 Convert a certificate from \s-1PEM\s0 to \s-1DER\s0 format:
764 .PP
765 .Vb 1
766 \& openssl x509 \-in cert.pem \-inform PEM \-out cert.der \-outform DER
767 .Ve
768 .PP
769 Convert a certificate to a certificate request:
770 .PP
771 .Vb 1
772 \& openssl x509 \-x509toreq \-in cert.pem \-out req.pem \-signkey key.pem
773 .Ve
774 .PP
775 Convert a certificate request into a self signed certificate using
776 extensions for a \s-1CA:\s0
777 .PP
778 .Vb 2
779 \& openssl x509 \-req \-in careq.pem \-extfile openssl.cnf \-extensions v3_ca \e
780 \&        \-signkey key.pem \-out cacert.pem
781 .Ve
782 .PP
783 Sign a certificate request using the \s-1CA\s0 certificate above and add user
784 certificate extensions:
785 .PP
786 .Vb 2
787 \& openssl x509 \-req \-in req.pem \-extfile openssl.cnf \-extensions v3_usr \e
788 \&        \-CA cacert.pem \-CAkey key.pem \-CAcreateserial
789 .Ve
790 .PP
791 Set a certificate to be trusted for \s-1SSL\s0 client use and change set its alias to
792 \&\*(L"Steve's Class 1 \s-1CA\*(R"\s0
793 .PP
794 .Vb 2
795 \& openssl x509 \-in cert.pem \-addtrust clientAuth \e
796 \&        \-setalias "Steve\*(Aqs Class 1 CA" \-out trust.pem
797 .Ve
798 .SH "NOTES"
799 .IX Header "NOTES"
800 The \s-1PEM\s0 format uses the header and footer lines:
801 .PP
802 .Vb 2
803 \& \-\-\-\-\-BEGIN CERTIFICATE\-\-\-\-\-
804 \& \-\-\-\-\-END CERTIFICATE\-\-\-\-\-
805 .Ve
806 .PP
807 it will also handle files containing:
808 .PP
809 .Vb 2
810 \& \-\-\-\-\-BEGIN X509 CERTIFICATE\-\-\-\-\-
811 \& \-\-\-\-\-END X509 CERTIFICATE\-\-\-\-\-
812 .Ve
813 .PP
814 Trusted certificates have the lines
815 .PP
816 .Vb 2
817 \& \-\-\-\-\-BEGIN TRUSTED CERTIFICATE\-\-\-\-\-
818 \& \-\-\-\-\-END TRUSTED CERTIFICATE\-\-\-\-\-
819 .Ve
820 .PP
821 The conversion to \s-1UTF8\s0 format used with the name options assumes that
822 T61Strings use the \s-1ISO8859\-1\s0 character set. This is wrong but Netscape
823 and \s-1MSIE\s0 do this as do many certificates. So although this is incorrect
824 it is more likely to display the majority of certificates correctly.
825 .PP
826 The \fB\-email\fR option searches the subject name and the subject alternative
827 name extension. Only unique email addresses will be printed out: it will
828 not print the same address more than once.
829 .SH "CERTIFICATE EXTENSIONS"
830 .IX Header "CERTIFICATE EXTENSIONS"
831 The \fB\-purpose\fR option checks the certificate extensions and determines
832 what the certificate can be used for. The actual checks done are rather
833 complex and include various hacks and workarounds to handle broken
834 certificates and software.
835 .PP
836 The same code is used when verifying untrusted certificates in chains
837 so this section is useful if a chain is rejected by the verify code.
838 .PP
839 The basicConstraints extension \s-1CA\s0 flag is used to determine whether the
840 certificate can be used as a \s-1CA.\s0 If the \s-1CA\s0 flag is true then it is a \s-1CA,\s0
841 if the \s-1CA\s0 flag is false then it is not a \s-1CA.\s0 \fBAll\fR CAs should have the
842 \&\s-1CA\s0 flag set to true.
843 .PP
844 If the basicConstraints extension is absent then the certificate is
845 considered to be a \*(L"possible \s-1CA\*(R"\s0 other extensions are checked according
846 to the intended use of the certificate. A warning is given in this case
847 because the certificate should really not be regarded as a \s-1CA:\s0 however
848 it is allowed to be a \s-1CA\s0 to work around some broken software.
849 .PP
850 If the certificate is a V1 certificate (and thus has no extensions) and
851 it is self signed it is also assumed to be a \s-1CA\s0 but a warning is again
852 given: this is to work around the problem of Verisign roots which are V1
853 self signed certificates.
854 .PP
855 If the keyUsage extension is present then additional restraints are
856 made on the uses of the certificate. A \s-1CA\s0 certificate \fBmust\fR have the
857 keyCertSign bit set if the keyUsage extension is present.
858 .PP
859 The extended key usage extension places additional restrictions on the
860 certificate uses. If this extension is present (whether critical or not)
861 the key can only be used for the purposes specified.
862 .PP
863 A complete description of each test is given below. The comments about
864 basicConstraints and keyUsage and V1 certificates above apply to \fBall\fR
865 \&\s-1CA\s0 certificates.
866 .IP "\fB\s-1SSL\s0 Client\fR" 4
867 .IX Item "SSL Client"
868 The extended key usage extension must be absent or include the \*(L"web client
869 authentication\*(R" \s-1OID.\s0  keyUsage must be absent or it must have the
870 digitalSignature bit set. Netscape certificate type must be absent or it must
871 have the \s-1SSL\s0 client bit set.
872 .IP "\fB\s-1SSL\s0 Client \s-1CA\s0\fR" 4
873 .IX Item "SSL Client CA"
874 The extended key usage extension must be absent or include the \*(L"web client
875 authentication\*(R" \s-1OID.\s0 Netscape certificate type must be absent or it must have
876 the \s-1SSL CA\s0 bit set: this is used as a work around if the basicConstraints
877 extension is absent.
878 .IP "\fB\s-1SSL\s0 Server\fR" 4
879 .IX Item "SSL Server"
880 The extended key usage extension must be absent or include the \*(L"web server
881 authentication\*(R" and/or one of the \s-1SGC\s0 OIDs.  keyUsage must be absent or it
882 must have the digitalSignature, the keyEncipherment set or both bits set.
883 Netscape certificate type must be absent or have the \s-1SSL\s0 server bit set.
884 .IP "\fB\s-1SSL\s0 Server \s-1CA\s0\fR" 4
885 .IX Item "SSL Server CA"
886 The extended key usage extension must be absent or include the \*(L"web server
887 authentication\*(R" and/or one of the \s-1SGC\s0 OIDs.  Netscape certificate type must
888 be absent or the \s-1SSL CA\s0 bit must be set: this is used as a work around if the
889 basicConstraints extension is absent.
890 .IP "\fBNetscape \s-1SSL\s0 Server\fR" 4
891 .IX Item "Netscape SSL Server"
892 For Netscape \s-1SSL\s0 clients to connect to an \s-1SSL\s0 server it must have the
893 keyEncipherment bit set if the keyUsage extension is present. This isn't
894 always valid because some cipher suites use the key for digital signing.
895 Otherwise it is the same as a normal \s-1SSL\s0 server.
896 .IP "\fBCommon S/MIME Client Tests\fR" 4
897 .IX Item "Common S/MIME Client Tests"
898 The extended key usage extension must be absent or include the \*(L"email
899 protection\*(R" \s-1OID.\s0 Netscape certificate type must be absent or should have the
900 S/MIME bit set. If the S/MIME bit is not set in Netscape certificate type
901 then the \s-1SSL\s0 client bit is tolerated as an alternative but a warning is shown:
902 this is because some Verisign certificates don't set the S/MIME bit.
903 .IP "\fBS/MIME Signing\fR" 4
904 .IX Item "S/MIME Signing"
905 In addition to the common S/MIME client tests the digitalSignature bit or
906 the nonRepudiation bit must be set if the keyUsage extension is present.
907 .IP "\fBS/MIME Encryption\fR" 4
908 .IX Item "S/MIME Encryption"
909 In addition to the common S/MIME tests the keyEncipherment bit must be set
910 if the keyUsage extension is present.
911 .IP "\fBS/MIME \s-1CA\s0\fR" 4
912 .IX Item "S/MIME CA"
913 The extended key usage extension must be absent or include the \*(L"email
914 protection\*(R" \s-1OID.\s0 Netscape certificate type must be absent or must have the
915 S/MIME \s-1CA\s0 bit set: this is used as a work around if the basicConstraints
916 extension is absent.
917 .IP "\fB\s-1CRL\s0 Signing\fR" 4
918 .IX Item "CRL Signing"
919 The keyUsage extension must be absent or it must have the \s-1CRL\s0 signing bit
920 set.
921 .IP "\fB\s-1CRL\s0 Signing \s-1CA\s0\fR" 4
922 .IX Item "CRL Signing CA"
923 The normal \s-1CA\s0 tests apply. Except in this case the basicConstraints extension
924 must be present.
925 .SH "BUGS"
926 .IX Header "BUGS"
927 Extensions in certificates are not transferred to certificate requests and
928 vice versa.
929 .PP
930 It is possible to produce invalid certificates or requests by specifying the
931 wrong private key or using inconsistent options in some cases: these should
932 be checked.
933 .PP
934 There should be options to explicitly set such things as start and end
935 dates rather than an offset from the current time.
936 .SH "SEE ALSO"
937 .IX Header "SEE ALSO"
938 \&\fBreq\fR\|(1), \fBca\fR\|(1), \fBgenrsa\fR\|(1),
939 \&\fBgendsa\fR\|(1), \fBverify\fR\|(1),
940 \&\fBx509v3_config\fR\|(5)
941 .SH "HISTORY"
942 .IX Header "HISTORY"
943 The hash algorithm used in the \fB\-subject_hash\fR and \fB\-issuer_hash\fR options
944 before OpenSSL 1.0.0 was based on the deprecated \s-1MD5\s0 algorithm and the encoding
945 of the distinguished name. In OpenSSL 1.0.0 and later it is based on a
946 canonical version of the \s-1DN\s0 using \s-1SHA1.\s0 This means that any directories using
947 the old form must have their links rebuilt using \fBc_rehash\fR or similar.
948 .SH "COPYRIGHT"
949 .IX Header "COPYRIGHT"
950 Copyright 2000\-2020 The OpenSSL Project Authors. All Rights Reserved.
951 .PP
952 Licensed under the OpenSSL license (the \*(L"License\*(R").  You may not use
953 this file except in compliance with the License.  You can obtain a copy
954 in the file \s-1LICENSE\s0 in the source distribution or at
955 <https://www.openssl.org/source/license.html>.