]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/usr.bin/openssl/man/x509.1
Merge OpenSSL 1.0.2q.
[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.0.2q" "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,
139 x509 \- Certificate display and signing utility
140 .SH "SYNOPSIS"
141 .IX Header "SYNOPSIS"
142 \&\fBopenssl\fR \fBx509\fR
143 [\fB\-inform DER|PEM|NET\fR]
144 [\fB\-outform DER|PEM|NET\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\-certopt option\fR]
189 [\fB\-C\fR]
190 [\fB\-md2|\-md5|\-sha1|\-mdc2\fR]
191 [\fB\-clrext\fR]
192 [\fB\-extfile filename\fR]
193 [\fB\-extensions section\fR]
194 [\fB\-engine id\fR]
195 .SH "DESCRIPTION"
196 .IX Header "DESCRIPTION"
197 The \fBx509\fR command is a multi purpose certificate utility. It can be
198 used to display certificate information, convert certificates to
199 various forms, sign certificate requests like a \*(L"mini \s-1CA\*(R"\s0 or edit
200 certificate trust settings.
201 .PP
202 Since there are a large number of options they will split up into
203 various sections.
204 .SH "OPTIONS"
205 .IX Header "OPTIONS"
206 .SS "\s-1INPUT, OUTPUT AND GENERAL PURPOSE OPTIONS\s0"
207 .IX Subsection "INPUT, OUTPUT AND GENERAL PURPOSE OPTIONS"
208 .IP "\fB\-inform DER|PEM|NET\fR" 4
209 .IX Item "-inform DER|PEM|NET"
210 This specifies the input format normally the command will expect an X509
211 certificate but this can change if other options such as \fB\-req\fR are
212 present. The \s-1DER\s0 format is the \s-1DER\s0 encoding of the certificate and \s-1PEM\s0
213 is the base64 encoding of the \s-1DER\s0 encoding with header and footer lines
214 added. The \s-1NET\s0 option is an obscure Netscape server format that is now
215 obsolete.
216 .IP "\fB\-outform DER|PEM|NET\fR" 4
217 .IX Item "-outform DER|PEM|NET"
218 This specifies the output format, the options have the same meaning as the 
219 \&\fB\-inform\fR option.
220 .IP "\fB\-in filename\fR" 4
221 .IX Item "-in filename"
222 This specifies the input filename to read a certificate from or standard input
223 if this option is not specified.
224 .IP "\fB\-out filename\fR" 4
225 .IX Item "-out filename"
226 This specifies the output filename to write to or standard output by
227 default.
228 .IP "\fB\-md2|\-md5|\-sha1|\-mdc2\fR" 4
229 .IX Item "-md2|-md5|-sha1|-mdc2"
230 the digest to use. This affects any signing or display option that uses a message
231 digest, such as the \fB\-fingerprint\fR, \fB\-signkey\fR and \fB\-CA\fR options. If not
232 specified then \s-1SHA1\s0 is used. If the key being used to sign with is a \s-1DSA\s0 key
233 then this option has no effect: \s-1SHA1\s0 is always used with \s-1DSA\s0 keys.
234 .IP "\fB\-engine id\fR" 4
235 .IX Item "-engine id"
236 specifying an engine (by its unique \fBid\fR string) will cause \fBx509\fR
237 to attempt to obtain a functional reference to the specified engine,
238 thus initialising it if needed. The engine will then be set as the default
239 for all available algorithms.
240 .SS "\s-1DISPLAY OPTIONS\s0"
241 .IX Subsection "DISPLAY OPTIONS"
242 Note: the \fB\-alias\fR and \fB\-purpose\fR options are also display options
243 but are described in the \fB\s-1TRUST SETTINGS\s0\fR section.
244 .IP "\fB\-text\fR" 4
245 .IX Item "-text"
246 prints out the certificate in text form. Full details are output including the
247 public key, signature algorithms, issuer and subject names, serial number
248 any extensions present and any trust settings.
249 .IP "\fB\-certopt option\fR" 4
250 .IX Item "-certopt option"
251 customise the output format used with \fB\-text\fR. The \fBoption\fR argument can be
252 a single option or multiple options separated by commas. The \fB\-certopt\fR switch
253 may be also be used more than once to set multiple options. See the \fB\s-1TEXT OPTIONS\s0\fR
254 section for more information.
255 .IP "\fB\-noout\fR" 4
256 .IX Item "-noout"
257 this option prevents output of the encoded version of the request.
258 .IP "\fB\-pubkey\fR" 4
259 .IX Item "-pubkey"
260 outputs the certificate's SubjectPublicKeyInfo block in \s-1PEM\s0 format.
261 .IP "\fB\-modulus\fR" 4
262 .IX Item "-modulus"
263 this option prints out the value of the modulus of the public key
264 contained in the certificate.
265 .IP "\fB\-serial\fR" 4
266 .IX Item "-serial"
267 outputs the certificate serial number.
268 .IP "\fB\-subject_hash\fR" 4
269 .IX Item "-subject_hash"
270 outputs the \*(L"hash\*(R" of the certificate subject name. This is used in OpenSSL to
271 form an index to allow certificates in a directory to be looked up by subject
272 name.
273 .IP "\fB\-issuer_hash\fR" 4
274 .IX Item "-issuer_hash"
275 outputs the \*(L"hash\*(R" of the certificate issuer name.
276 .IP "\fB\-ocspid\fR" 4
277 .IX Item "-ocspid"
278 outputs the \s-1OCSP\s0 hash values for the subject name and public key.
279 .IP "\fB\-hash\fR" 4
280 .IX Item "-hash"
281 synonym for \*(L"\-subject_hash\*(R" for backward compatibility reasons.
282 .IP "\fB\-subject_hash_old\fR" 4
283 .IX Item "-subject_hash_old"
284 outputs the \*(L"hash\*(R" of the certificate subject name using the older algorithm
285 as used by OpenSSL versions before 1.0.0.
286 .IP "\fB\-issuer_hash_old\fR" 4
287 .IX Item "-issuer_hash_old"
288 outputs the \*(L"hash\*(R" of the certificate issuer name using the older algorithm
289 as used by OpenSSL versions before 1.0.0.
290 .IP "\fB\-subject\fR" 4
291 .IX Item "-subject"
292 outputs the subject name.
293 .IP "\fB\-issuer\fR" 4
294 .IX Item "-issuer"
295 outputs the issuer name.
296 .IP "\fB\-nameopt option\fR" 4
297 .IX Item "-nameopt option"
298 option which determines how the subject or issuer names are displayed. The
299 \&\fBoption\fR argument can be a single option or multiple options separated by
300 commas.  Alternatively the \fB\-nameopt\fR switch may be used more than once to
301 set multiple options. See the \fB\s-1NAME OPTIONS\s0\fR section for more information.
302 .IP "\fB\-email\fR" 4
303 .IX Item "-email"
304 outputs the email address(es) if any.
305 .IP "\fB\-ocsp_uri\fR" 4
306 .IX Item "-ocsp_uri"
307 outputs the \s-1OCSP\s0 responder address(es) if any.
308 .IP "\fB\-startdate\fR" 4
309 .IX Item "-startdate"
310 prints out the start date of the certificate, that is the notBefore date.
311 .IP "\fB\-enddate\fR" 4
312 .IX Item "-enddate"
313 prints out the expiry date of the certificate, that is the notAfter date.
314 .IP "\fB\-dates\fR" 4
315 .IX Item "-dates"
316 prints out the start and expiry dates of a certificate.
317 .IP "\fB\-checkend arg\fR" 4
318 .IX Item "-checkend arg"
319 checks if the certificate expires within the next \fBarg\fR seconds and exits
320 non-zero if yes it will expire or zero if not.
321 .IP "\fB\-fingerprint\fR" 4
322 .IX Item "-fingerprint"
323 Calculates and outputs the digest of the \s-1DER\s0 encoded version of the entire
324 certificate (see digest options).
325 This is commonly called a \*(L"fingerprint\*(R". Because of the nature of message
326 digests, the fingerprint of a certificate is unique to that certificate and
327 two certificates with the same fingerprint can be considered to be the same.
328 .IP "\fB\-C\fR" 4
329 .IX Item "-C"
330 this outputs the certificate in the form of a C source file.
331 .SS "\s-1TRUST SETTINGS\s0"
332 .IX Subsection "TRUST SETTINGS"
333 Please note these options are currently experimental and may well change.
334 .PP
335 A \fBtrusted certificate\fR is an ordinary certificate which has several
336 additional pieces of information attached to it such as the permitted
337 and prohibited uses of the certificate and an \*(L"alias\*(R".
338 .PP
339 Normally when a certificate is being verified at least one certificate
340 must be \*(L"trusted\*(R". By default a trusted certificate must be stored
341 locally and must be a root \s-1CA:\s0 any certificate chain ending in this \s-1CA\s0
342 is then usable for any purpose.
343 .PP
344 Trust settings currently are only used with a root \s-1CA.\s0 They allow a finer
345 control over the purposes the root \s-1CA\s0 can be used for. For example a \s-1CA\s0
346 may be trusted for \s-1SSL\s0 client but not \s-1SSL\s0 server use.
347 .PP
348 See the description of the \fBverify\fR utility for more information on the
349 meaning of trust settings.
350 .PP
351 Future versions of OpenSSL will recognize trust settings on any
352 certificate: not just root CAs.
353 .IP "\fB\-trustout\fR" 4
354 .IX Item "-trustout"
355 this causes \fBx509\fR to output a \fBtrusted\fR certificate. An ordinary
356 or trusted certificate can be input but by default an ordinary
357 certificate is output and any trust settings are discarded. With the
358 \&\fB\-trustout\fR option a trusted certificate is output. A trusted
359 certificate is automatically output if any trust settings are modified.
360 .IP "\fB\-setalias arg\fR" 4
361 .IX Item "-setalias arg"
362 sets the alias of the certificate. This will allow the certificate
363 to be referred to using a nickname for example \*(L"Steve's Certificate\*(R".
364 .IP "\fB\-alias\fR" 4
365 .IX Item "-alias"
366 outputs the certificate alias, if any.
367 .IP "\fB\-clrtrust\fR" 4
368 .IX Item "-clrtrust"
369 clears all the permitted or trusted uses of the certificate.
370 .IP "\fB\-clrreject\fR" 4
371 .IX Item "-clrreject"
372 clears all the prohibited or rejected uses of the certificate.
373 .IP "\fB\-addtrust arg\fR" 4
374 .IX Item "-addtrust arg"
375 adds a trusted certificate use. Any object name can be used here
376 but currently only \fBclientAuth\fR (\s-1SSL\s0 client use), \fBserverAuth\fR
377 (\s-1SSL\s0 server use) and \fBemailProtection\fR (S/MIME email) are used.
378 Other OpenSSL applications may define additional uses.
379 .IP "\fB\-addreject arg\fR" 4
380 .IX Item "-addreject arg"
381 adds a prohibited use. It accepts the same values as the \fB\-addtrust\fR
382 option.
383 .IP "\fB\-purpose\fR" 4
384 .IX Item "-purpose"
385 this option performs tests on the certificate extensions and outputs
386 the results. For a more complete description see the \fB\s-1CERTIFICATE
387 EXTENSIONS\s0\fR section.
388 .SS "\s-1SIGNING OPTIONS\s0"
389 .IX Subsection "SIGNING OPTIONS"
390 The \fBx509\fR utility can be used to sign certificates and requests: it
391 can thus behave like a \*(L"mini \s-1CA\*(R".\s0
392 .IP "\fB\-signkey filename\fR" 4
393 .IX Item "-signkey filename"
394 this option causes the input file to be self signed using the supplied
395 private key.
396 .Sp
397 If the input file is a certificate it sets the issuer name to the
398 subject name (i.e.  makes it self signed) changes the public key to the
399 supplied value and changes the start and end dates. The start date is
400 set to the current time and the end date is set to a value determined
401 by the \fB\-days\fR option. Any certificate extensions are retained unless
402 the \fB\-clrext\fR option is supplied.
403 .Sp
404 If the input is a certificate request then a self signed certificate
405 is created using the supplied private key using the subject name in
406 the request.
407 .IP "\fB\-passin arg\fR" 4
408 .IX Item "-passin arg"
409 the key password source. For more information about the format of \fBarg\fR
410 see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1).
411 .IP "\fB\-clrext\fR" 4
412 .IX Item "-clrext"
413 delete any extensions from a certificate. This option is used when a
414 certificate is being created from another certificate (for example with
415 the \fB\-signkey\fR or the \fB\-CA\fR options). Normally all extensions are
416 retained.
417 .IP "\fB\-keyform PEM|DER\fR" 4
418 .IX Item "-keyform PEM|DER"
419 specifies the format (\s-1DER\s0 or \s-1PEM\s0) of the private key file used in the
420 \&\fB\-signkey\fR option.
421 .IP "\fB\-days arg\fR" 4
422 .IX Item "-days arg"
423 specifies the number of days to make a certificate valid for. The default
424 is 30 days.
425 .IP "\fB\-x509toreq\fR" 4
426 .IX Item "-x509toreq"
427 converts a certificate into a certificate request. The \fB\-signkey\fR option
428 is used to pass the required private key.
429 .IP "\fB\-req\fR" 4
430 .IX Item "-req"
431 by default a certificate is expected on input. With this option a
432 certificate request is expected instead.
433 .IP "\fB\-set_serial n\fR" 4
434 .IX Item "-set_serial n"
435 specifies the serial number to use. This option can be used with either
436 the \fB\-signkey\fR or \fB\-CA\fR options. If used in conjunction with the \fB\-CA\fR
437 option the serial number file (as specified by the \fB\-CAserial\fR or
438 \&\fB\-CAcreateserial\fR options) is not used.
439 .Sp
440 The serial number can be decimal or hex (if preceded by \fB0x\fR). Negative
441 serial numbers can also be specified but their use is not recommended.
442 .IP "\fB\-CA filename\fR" 4
443 .IX Item "-CA filename"
444 specifies the \s-1CA\s0 certificate to be used for signing. When this option is
445 present \fBx509\fR behaves like a \*(L"mini \s-1CA\*(R".\s0 The input file is signed by this
446 \&\s-1CA\s0 using this option: that is its issuer name is set to the subject name
447 of the \s-1CA\s0 and it is digitally signed using the CAs private key.
448 .Sp
449 This option is normally combined with the \fB\-req\fR option. Without the
450 \&\fB\-req\fR option the input is a certificate which must be self signed.
451 .IP "\fB\-CAkey filename\fR" 4
452 .IX Item "-CAkey filename"
453 sets the \s-1CA\s0 private key to sign a certificate with. If this option is
454 not specified then it is assumed that the \s-1CA\s0 private key is present in
455 the \s-1CA\s0 certificate file.
456 .IP "\fB\-CAserial filename\fR" 4
457 .IX Item "-CAserial filename"
458 sets the \s-1CA\s0 serial number file to use.
459 .Sp
460 When the \fB\-CA\fR option is used to sign a certificate it uses a serial
461 number specified in a file. This file consist of one line containing
462 an even number of hex digits with the serial number to use. After each
463 use the serial number is incremented and written out to the file again.
464 .Sp
465 The default filename consists of the \s-1CA\s0 certificate file base name with
466 \&\*(L".srl\*(R" appended. For example if the \s-1CA\s0 certificate file is called 
467 \&\*(L"mycacert.pem\*(R" it expects to find a serial number file called \*(L"mycacert.srl\*(R".
468 .IP "\fB\-CAcreateserial\fR" 4
469 .IX Item "-CAcreateserial"
470 with this option the \s-1CA\s0 serial number file is created if it does not exist:
471 it will contain the serial number \*(L"02\*(R" and the certificate being signed will
472 have the 1 as its serial number. Normally if the \fB\-CA\fR option is specified
473 and the serial number file does not exist it is an error.
474 .IP "\fB\-extfile filename\fR" 4
475 .IX Item "-extfile filename"
476 file containing certificate extensions to use. If not specified then
477 no extensions are added to the certificate.
478 .IP "\fB\-extensions section\fR" 4
479 .IX Item "-extensions section"
480 the section to add certificate extensions from. If this option is not
481 specified then the extensions should either be contained in the unnamed
482 (default) section or the default section should contain a variable called
483 \&\*(L"extensions\*(R" which contains the section to use. See the
484 \&\fIx509v3_config\fR\|(5) manual page for details of the
485 extension section format.
486 .IP "\fB\-force_pubkey key\fR" 4
487 .IX Item "-force_pubkey key"
488 when a certificate is created set its public key to \fBkey\fR instead of the
489 key in the certificate or certificate request. This option is useful for
490 creating certificates where the algorithm can't normally sign requests, for
491 example \s-1DH.\s0
492 .Sp
493 The format or \fBkey\fR can be specified using the \fB\-keyform\fR option.
494 .SS "\s-1NAME OPTIONS\s0"
495 .IX Subsection "NAME OPTIONS"
496 The \fBnameopt\fR command line switch determines how the subject and issuer
497 names are displayed. If no \fBnameopt\fR switch is present the default \*(L"oneline\*(R"
498 format is used which is compatible with previous versions of OpenSSL.
499 Each option is described in detail below, all options can be preceded by
500 a \fB\-\fR to turn the option off. Only the first four will normally be used.
501 .IP "\fBcompat\fR" 4
502 .IX Item "compat"
503 use the old format. This is equivalent to specifying no name options at all.
504 .IP "\fB\s-1RFC2253\s0\fR" 4
505 .IX Item "RFC2253"
506 displays names compatible with \s-1RFC2253\s0 equivalent to \fBesc_2253\fR, \fBesc_ctrl\fR,
507 \&\fBesc_msb\fR, \fButf8\fR, \fBdump_nostr\fR, \fBdump_unknown\fR, \fBdump_der\fR,
508 \&\fBsep_comma_plus\fR, \fBdn_rev\fR and \fBsname\fR.
509 .IP "\fBoneline\fR" 4
510 .IX Item "oneline"
511 a oneline format which is more readable than \s-1RFC2253.\s0 It is equivalent to
512 specifying the  \fBesc_2253\fR, \fBesc_ctrl\fR, \fBesc_msb\fR, \fButf8\fR, \fBdump_nostr\fR,
513 \&\fBdump_der\fR, \fBuse_quote\fR, \fBsep_comma_plus_space\fR, \fBspace_eq\fR and \fBsname\fR
514 options.
515 .IP "\fBmultiline\fR" 4
516 .IX Item "multiline"
517 a multiline format. It is equivalent \fBesc_ctrl\fR, \fBesc_msb\fR, \fBsep_multiline\fR,
518 \&\fBspace_eq\fR, \fBlname\fR and \fBalign\fR.
519 .IP "\fBesc_2253\fR" 4
520 .IX Item "esc_2253"
521 escape the \*(L"special\*(R" characters required by \s-1RFC2253\s0 in a field That is
522 \&\fB,+"<>;\fR. Additionally \fB#\fR is escaped at the beginning of a string
523 and a space character at the beginning or end of a string.
524 .IP "\fBesc_ctrl\fR" 4
525 .IX Item "esc_ctrl"
526 escape control characters. That is those with \s-1ASCII\s0 values less than
527 0x20 (space) and the delete (0x7f) character. They are escaped using the
528 \&\s-1RFC2253\s0 \eXX notation (where \s-1XX\s0 are two hex digits representing the
529 character value).
530 .IP "\fBesc_msb\fR" 4
531 .IX Item "esc_msb"
532 escape characters with the \s-1MSB\s0 set, that is with \s-1ASCII\s0 values larger than
533 127.
534 .IP "\fBuse_quote\fR" 4
535 .IX Item "use_quote"
536 escapes some characters by surrounding the whole string with \fB"\fR characters,
537 without the option all escaping is done with the \fB\e\fR character.
538 .IP "\fButf8\fR" 4
539 .IX Item "utf8"
540 convert all strings to \s-1UTF8\s0 format first. This is required by \s-1RFC2253.\s0 If
541 you are lucky enough to have a \s-1UTF8\s0 compatible terminal then the use
542 of this option (and \fBnot\fR setting \fBesc_msb\fR) may result in the correct
543 display of multibyte (international) characters. Is this option is not
544 present then multibyte characters larger than 0xff will be represented
545 using the format \eUXXXX for 16 bits and \eWXXXXXXXX for 32 bits.
546 Also if this option is off any UTF8Strings will be converted to their
547 character form first.
548 .IP "\fBignore_type\fR" 4
549 .IX Item "ignore_type"
550 this option does not attempt to interpret multibyte characters in any
551 way. That is their content octets are merely dumped as though one octet
552 represents each character. This is useful for diagnostic purposes but
553 will result in rather odd looking output.
554 .IP "\fBshow_type\fR" 4
555 .IX Item "show_type"
556 show the type of the \s-1ASN1\s0 character string. The type precedes the
557 field contents. For example \*(L"\s-1BMPSTRING:\s0 Hello World\*(R".
558 .IP "\fBdump_der\fR" 4
559 .IX Item "dump_der"
560 when this option is set any fields that need to be hexdumped will
561 be dumped using the \s-1DER\s0 encoding of the field. Otherwise just the
562 content octets will be displayed. Both options use the \s-1RFC2253\s0
563 \&\fB#XXXX...\fR format.
564 .IP "\fBdump_nostr\fR" 4
565 .IX Item "dump_nostr"
566 dump non character string types (for example \s-1OCTET STRING\s0) if this
567 option is not set then non character string types will be displayed
568 as though each content octet represents a single character.
569 .IP "\fBdump_all\fR" 4
570 .IX Item "dump_all"
571 dump all fields. This option when used with \fBdump_der\fR allows the
572 \&\s-1DER\s0 encoding of the structure to be unambiguously determined.
573 .IP "\fBdump_unknown\fR" 4
574 .IX Item "dump_unknown"
575 dump any field whose \s-1OID\s0 is not recognised by OpenSSL.
576 .IP "\fBsep_comma_plus\fR, \fBsep_comma_plus_space\fR, \fBsep_semi_plus_space\fR, \fBsep_multiline\fR" 4
577 .IX Item "sep_comma_plus, sep_comma_plus_space, sep_semi_plus_space, sep_multiline"
578 these options determine the field separators. The first character is
579 between RDNs and the second between multiple AVAs (multiple AVAs are
580 very rare and their use is discouraged). The options ending in
581 \&\*(L"space\*(R" additionally place a space after the separator to make it
582 more readable. The \fBsep_multiline\fR uses a linefeed character for
583 the \s-1RDN\s0 separator and a spaced \fB+\fR for the \s-1AVA\s0 separator. It also
584 indents the fields by four characters. If no field separator is specified
585 then \fBsep_comma_plus_space\fR is used by default.
586 .IP "\fBdn_rev\fR" 4
587 .IX Item "dn_rev"
588 reverse the fields of the \s-1DN.\s0 This is required by \s-1RFC2253.\s0 As a side
589 effect this also reverses the order of multiple AVAs but this is
590 permissible.
591 .IP "\fBnofname\fR, \fBsname\fR, \fBlname\fR, \fBoid\fR" 4
592 .IX Item "nofname, sname, lname, oid"
593 these options alter how the field name is displayed. \fBnofname\fR does
594 not display the field at all. \fBsname\fR uses the \*(L"short name\*(R" form
595 (\s-1CN\s0 for commonName for example). \fBlname\fR uses the long form.
596 \&\fBoid\fR represents the \s-1OID\s0 in numerical form and is useful for
597 diagnostic purpose.
598 .IP "\fBalign\fR" 4
599 .IX Item "align"
600 align field values for a more readable output. Only usable with
601 \&\fBsep_multiline\fR.
602 .IP "\fBspace_eq\fR" 4
603 .IX Item "space_eq"
604 places spaces round the \fB=\fR character which follows the field
605 name.
606 .SS "\s-1TEXT OPTIONS\s0"
607 .IX Subsection "TEXT OPTIONS"
608 As well as customising the name output format, it is also possible to
609 customise the actual fields printed using the \fBcertopt\fR options when
610 the \fBtext\fR option is present. The default behaviour is to print all fields.
611 .IP "\fBcompatible\fR" 4
612 .IX Item "compatible"
613 use the old format. This is equivalent to specifying no output options at all.
614 .IP "\fBno_header\fR" 4
615 .IX Item "no_header"
616 don't print header information: that is the lines saying \*(L"Certificate\*(R" and \*(L"Data\*(R".
617 .IP "\fBno_version\fR" 4
618 .IX Item "no_version"
619 don't print out the version number.
620 .IP "\fBno_serial\fR" 4
621 .IX Item "no_serial"
622 don't print out the serial number.
623 .IP "\fBno_signame\fR" 4
624 .IX Item "no_signame"
625 don't print out the signature algorithm used.
626 .IP "\fBno_validity\fR" 4
627 .IX Item "no_validity"
628 don't print the validity, that is the \fBnotBefore\fR and \fBnotAfter\fR fields.
629 .IP "\fBno_subject\fR" 4
630 .IX Item "no_subject"
631 don't print out the subject name.
632 .IP "\fBno_issuer\fR" 4
633 .IX Item "no_issuer"
634 don't print out the issuer name.
635 .IP "\fBno_pubkey\fR" 4
636 .IX Item "no_pubkey"
637 don't print out the public key.
638 .IP "\fBno_sigdump\fR" 4
639 .IX Item "no_sigdump"
640 don't give a hexadecimal dump of the certificate signature.
641 .IP "\fBno_aux\fR" 4
642 .IX Item "no_aux"
643 don't print out certificate trust information.
644 .IP "\fBno_extensions\fR" 4
645 .IX Item "no_extensions"
646 don't print out any X509V3 extensions.
647 .IP "\fBext_default\fR" 4
648 .IX Item "ext_default"
649 retain default extension behaviour: attempt to print out unsupported certificate extensions.
650 .IP "\fBext_error\fR" 4
651 .IX Item "ext_error"
652 print an error message for unsupported certificate extensions.
653 .IP "\fBext_parse\fR" 4
654 .IX Item "ext_parse"
655 \&\s-1ASN1\s0 parse unsupported extensions.
656 .IP "\fBext_dump\fR" 4
657 .IX Item "ext_dump"
658 hex dump unsupported extensions.
659 .IP "\fBca_default\fR" 4
660 .IX Item "ca_default"
661 the value used by the \fBca\fR utility, equivalent to \fBno_issuer\fR, \fBno_pubkey\fR,
662 \&\fBno_header\fR, and \fBno_version\fR.
663 .SH "EXAMPLES"
664 .IX Header "EXAMPLES"
665 Note: in these examples the '\e' means the example should be all on one
666 line.
667 .PP
668 Display the contents of a certificate:
669 .PP
670 .Vb 1
671 \& openssl x509 \-in cert.pem \-noout \-text
672 .Ve
673 .PP
674 Display the certificate serial number:
675 .PP
676 .Vb 1
677 \& openssl x509 \-in cert.pem \-noout \-serial
678 .Ve
679 .PP
680 Display the certificate subject name:
681 .PP
682 .Vb 1
683 \& openssl x509 \-in cert.pem \-noout \-subject
684 .Ve
685 .PP
686 Display the certificate subject name in \s-1RFC2253\s0 form:
687 .PP
688 .Vb 1
689 \& openssl x509 \-in cert.pem \-noout \-subject \-nameopt RFC2253
690 .Ve
691 .PP
692 Display the certificate subject name in oneline form on a terminal
693 supporting \s-1UTF8:\s0
694 .PP
695 .Vb 1
696 \& openssl x509 \-in cert.pem \-noout \-subject \-nameopt oneline,\-esc_msb
697 .Ve
698 .PP
699 Display the certificate \s-1SHA1\s0 fingerprint:
700 .PP
701 .Vb 1
702 \& openssl x509 \-sha1 \-in cert.pem \-noout \-fingerprint
703 .Ve
704 .PP
705 Convert a certificate from \s-1PEM\s0 to \s-1DER\s0 format:
706 .PP
707 .Vb 1
708 \& openssl x509 \-in cert.pem \-inform PEM \-out cert.der \-outform DER
709 .Ve
710 .PP
711 Convert a certificate to a certificate request:
712 .PP
713 .Vb 1
714 \& openssl x509 \-x509toreq \-in cert.pem \-out req.pem \-signkey key.pem
715 .Ve
716 .PP
717 Convert a certificate request into a self signed certificate using
718 extensions for a \s-1CA:\s0
719 .PP
720 .Vb 2
721 \& openssl x509 \-req \-in careq.pem \-extfile openssl.cnf \-extensions v3_ca \e
722 \&        \-signkey key.pem \-out cacert.pem
723 .Ve
724 .PP
725 Sign a certificate request using the \s-1CA\s0 certificate above and add user
726 certificate extensions:
727 .PP
728 .Vb 2
729 \& openssl x509 \-req \-in req.pem \-extfile openssl.cnf \-extensions v3_usr \e
730 \&        \-CA cacert.pem \-CAkey key.pem \-CAcreateserial
731 .Ve
732 .PP
733 Set a certificate to be trusted for \s-1SSL\s0 client use and change set its alias to
734 \&\*(L"Steve's Class 1 \s-1CA\*(R"\s0
735 .PP
736 .Vb 2
737 \& openssl x509 \-in cert.pem \-addtrust clientAuth \e
738 \&        \-setalias "Steve\*(Aqs Class 1 CA" \-out trust.pem
739 .Ve
740 .SH "NOTES"
741 .IX Header "NOTES"
742 The \s-1PEM\s0 format uses the header and footer lines:
743 .PP
744 .Vb 2
745 \& \-\-\-\-\-BEGIN CERTIFICATE\-\-\-\-\-
746 \& \-\-\-\-\-END CERTIFICATE\-\-\-\-\-
747 .Ve
748 .PP
749 it will also handle files containing:
750 .PP
751 .Vb 2
752 \& \-\-\-\-\-BEGIN X509 CERTIFICATE\-\-\-\-\-
753 \& \-\-\-\-\-END X509 CERTIFICATE\-\-\-\-\-
754 .Ve
755 .PP
756 Trusted certificates have the lines
757 .PP
758 .Vb 2
759 \& \-\-\-\-\-BEGIN TRUSTED CERTIFICATE\-\-\-\-\-
760 \& \-\-\-\-\-END TRUSTED CERTIFICATE\-\-\-\-\-
761 .Ve
762 .PP
763 The conversion to \s-1UTF8\s0 format used with the name options assumes that
764 T61Strings use the \s-1ISO8859\-1\s0 character set. This is wrong but Netscape
765 and \s-1MSIE\s0 do this as do many certificates. So although this is incorrect
766 it is more likely to display the majority of certificates correctly.
767 .PP
768 The \fB\-email\fR option searches the subject name and the subject alternative
769 name extension. Only unique email addresses will be printed out: it will
770 not print the same address more than once.
771 .SH "CERTIFICATE EXTENSIONS"
772 .IX Header "CERTIFICATE EXTENSIONS"
773 The \fB\-purpose\fR option checks the certificate extensions and determines
774 what the certificate can be used for. The actual checks done are rather
775 complex and include various hacks and workarounds to handle broken
776 certificates and software.
777 .PP
778 The same code is used when verifying untrusted certificates in chains
779 so this section is useful if a chain is rejected by the verify code.
780 .PP
781 The basicConstraints extension \s-1CA\s0 flag is used to determine whether the
782 certificate can be used as a \s-1CA.\s0 If the \s-1CA\s0 flag is true then it is a \s-1CA,\s0
783 if the \s-1CA\s0 flag is false then it is not a \s-1CA.\s0 \fBAll\fR CAs should have the
784 \&\s-1CA\s0 flag set to true.
785 .PP
786 If the basicConstraints extension is absent then the certificate is
787 considered to be a \*(L"possible \s-1CA\*(R"\s0 other extensions are checked according
788 to the intended use of the certificate. A warning is given in this case
789 because the certificate should really not be regarded as a \s-1CA:\s0 however
790 it is allowed to be a \s-1CA\s0 to work around some broken software.
791 .PP
792 If the certificate is a V1 certificate (and thus has no extensions) and
793 it is self signed it is also assumed to be a \s-1CA\s0 but a warning is again
794 given: this is to work around the problem of Verisign roots which are V1
795 self signed certificates.
796 .PP
797 If the keyUsage extension is present then additional restraints are
798 made on the uses of the certificate. A \s-1CA\s0 certificate \fBmust\fR have the
799 keyCertSign bit set if the keyUsage extension is present.
800 .PP
801 The extended key usage extension places additional restrictions on the
802 certificate uses. If this extension is present (whether critical or not)
803 the key can only be used for the purposes specified.
804 .PP
805 A complete description of each test is given below. The comments about
806 basicConstraints and keyUsage and V1 certificates above apply to \fBall\fR
807 \&\s-1CA\s0 certificates.
808 .IP "\fB\s-1SSL\s0 Client\fR" 4
809 .IX Item "SSL Client"
810 The extended key usage extension must be absent or include the \*(L"web client
811 authentication\*(R" \s-1OID.\s0  keyUsage must be absent or it must have the
812 digitalSignature bit set. Netscape certificate type must be absent or it must
813 have the \s-1SSL\s0 client bit set.
814 .IP "\fB\s-1SSL\s0 Client \s-1CA\s0\fR" 4
815 .IX Item "SSL Client CA"
816 The extended key usage extension must be absent or include the \*(L"web client
817 authentication\*(R" \s-1OID.\s0 Netscape certificate type must be absent or it must have
818 the \s-1SSL CA\s0 bit set: this is used as a work around if the basicConstraints
819 extension is absent.
820 .IP "\fB\s-1SSL\s0 Server\fR" 4
821 .IX Item "SSL Server"
822 The extended key usage extension must be absent or include the \*(L"web server
823 authentication\*(R" and/or one of the \s-1SGC\s0 OIDs.  keyUsage must be absent or it
824 must have the digitalSignature, the keyEncipherment set or both bits set.
825 Netscape certificate type must be absent or have the \s-1SSL\s0 server bit set.
826 .IP "\fB\s-1SSL\s0 Server \s-1CA\s0\fR" 4
827 .IX Item "SSL Server CA"
828 The extended key usage extension must be absent or include the \*(L"web server
829 authentication\*(R" and/or one of the \s-1SGC\s0 OIDs.  Netscape certificate type must
830 be absent or the \s-1SSL CA\s0 bit must be set: this is used as a work around if the
831 basicConstraints extension is absent.
832 .IP "\fBNetscape \s-1SSL\s0 Server\fR" 4
833 .IX Item "Netscape SSL Server"
834 For Netscape \s-1SSL\s0 clients to connect to an \s-1SSL\s0 server it must have the
835 keyEncipherment bit set if the keyUsage extension is present. This isn't
836 always valid because some cipher suites use the key for digital signing.
837 Otherwise it is the same as a normal \s-1SSL\s0 server.
838 .IP "\fBCommon S/MIME Client Tests\fR" 4
839 .IX Item "Common S/MIME Client Tests"
840 The extended key usage extension must be absent or include the \*(L"email
841 protection\*(R" \s-1OID.\s0 Netscape certificate type must be absent or should have the
842 S/MIME bit set. If the S/MIME bit is not set in netscape certificate type
843 then the \s-1SSL\s0 client bit is tolerated as an alternative but a warning is shown:
844 this is because some Verisign certificates don't set the S/MIME bit.
845 .IP "\fBS/MIME Signing\fR" 4
846 .IX Item "S/MIME Signing"
847 In addition to the common S/MIME client tests the digitalSignature bit must
848 be set if the keyUsage extension is present.
849 .IP "\fBS/MIME Encryption\fR" 4
850 .IX Item "S/MIME Encryption"
851 In addition to the common S/MIME tests the keyEncipherment bit must be set
852 if the keyUsage extension is present.
853 .IP "\fBS/MIME \s-1CA\s0\fR" 4
854 .IX Item "S/MIME CA"
855 The extended key usage extension must be absent or include the \*(L"email
856 protection\*(R" \s-1OID.\s0 Netscape certificate type must be absent or must have the
857 S/MIME \s-1CA\s0 bit set: this is used as a work around if the basicConstraints
858 extension is absent.
859 .IP "\fB\s-1CRL\s0 Signing\fR" 4
860 .IX Item "CRL Signing"
861 The keyUsage extension must be absent or it must have the \s-1CRL\s0 signing bit
862 set.
863 .IP "\fB\s-1CRL\s0 Signing \s-1CA\s0\fR" 4
864 .IX Item "CRL Signing CA"
865 The normal \s-1CA\s0 tests apply. Except in this case the basicConstraints extension
866 must be present.
867 .SH "BUGS"
868 .IX Header "BUGS"
869 Extensions in certificates are not transferred to certificate requests and
870 vice versa.
871 .PP
872 It is possible to produce invalid certificates or requests by specifying the
873 wrong private key or using inconsistent options in some cases: these should
874 be checked.
875 .PP
876 There should be options to explicitly set such things as start and end
877 dates rather than an offset from the current time.
878 .PP
879 The code to implement the verify behaviour described in the \fB\s-1TRUST SETTINGS\s0\fR
880 is currently being developed. It thus describes the intended behaviour rather
881 than the current behaviour. It is hoped that it will represent reality in
882 OpenSSL 0.9.5 and later.
883 .SH "SEE ALSO"
884 .IX Header "SEE ALSO"
885 \&\fIreq\fR\|(1), \fIca\fR\|(1), \fIgenrsa\fR\|(1),
886 \&\fIgendsa\fR\|(1), \fIverify\fR\|(1),
887 \&\fIx509v3_config\fR\|(5)
888 .SH "HISTORY"
889 .IX Header "HISTORY"
890 Before OpenSSL 0.9.8, the default digest for \s-1RSA\s0 keys was \s-1MD5.\s0
891 .PP
892 The hash algorithm used in the \fB\-subject_hash\fR and \fB\-issuer_hash\fR options
893 before OpenSSL 1.0.0 was based on the deprecated \s-1MD5\s0 algorithm and the encoding
894 of the distinguished name. In OpenSSL 1.0.0 and later it is based on a
895 canonical version of the \s-1DN\s0 using \s-1SHA1.\s0 This means that any directories using
896 the old form must have their links rebuilt using \fBc_rehash\fR or similar.