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