xref: /onnv-gate/usr/src/common/openssl/doc/apps/x509.pod (revision 2175:b0b2f052a486)
1*2175Sjp161948
2*2175Sjp161948=pod
3*2175Sjp161948
4*2175Sjp161948=head1 NAME
5*2175Sjp161948
6*2175Sjp161948x509 - Certificate display and signing utility
7*2175Sjp161948
8*2175Sjp161948=head1 SYNOPSIS
9*2175Sjp161948
10*2175Sjp161948B<openssl> B<x509>
11*2175Sjp161948[B<-inform DER|PEM|NET>]
12*2175Sjp161948[B<-outform DER|PEM|NET>]
13*2175Sjp161948[B<-keyform DER|PEM>]
14*2175Sjp161948[B<-CAform DER|PEM>]
15*2175Sjp161948[B<-CAkeyform DER|PEM>]
16*2175Sjp161948[B<-in filename>]
17*2175Sjp161948[B<-out filename>]
18*2175Sjp161948[B<-serial>]
19*2175Sjp161948[B<-hash>]
20*2175Sjp161948[B<-subject_hash>]
21*2175Sjp161948[B<-issuer_hash>]
22*2175Sjp161948[B<-subject>]
23*2175Sjp161948[B<-issuer>]
24*2175Sjp161948[B<-nameopt option>]
25*2175Sjp161948[B<-email>]
26*2175Sjp161948[B<-startdate>]
27*2175Sjp161948[B<-enddate>]
28*2175Sjp161948[B<-purpose>]
29*2175Sjp161948[B<-dates>]
30*2175Sjp161948[B<-modulus>]
31*2175Sjp161948[B<-fingerprint>]
32*2175Sjp161948[B<-alias>]
33*2175Sjp161948[B<-noout>]
34*2175Sjp161948[B<-trustout>]
35*2175Sjp161948[B<-clrtrust>]
36*2175Sjp161948[B<-clrreject>]
37*2175Sjp161948[B<-addtrust arg>]
38*2175Sjp161948[B<-addreject arg>]
39*2175Sjp161948[B<-setalias arg>]
40*2175Sjp161948[B<-days arg>]
41*2175Sjp161948[B<-set_serial n>]
42*2175Sjp161948[B<-signkey filename>]
43*2175Sjp161948[B<-x509toreq>]
44*2175Sjp161948[B<-req>]
45*2175Sjp161948[B<-CA filename>]
46*2175Sjp161948[B<-CAkey filename>]
47*2175Sjp161948[B<-CAcreateserial>]
48*2175Sjp161948[B<-CAserial filename>]
49*2175Sjp161948[B<-text>]
50*2175Sjp161948[B<-C>]
51*2175Sjp161948[B<-md2|-md5|-sha1|-mdc2>]
52*2175Sjp161948[B<-clrext>]
53*2175Sjp161948[B<-extfile filename>]
54*2175Sjp161948[B<-extensions section>]
55*2175Sjp161948[B<-engine id>]
56*2175Sjp161948
57*2175Sjp161948=head1 DESCRIPTION
58*2175Sjp161948
59*2175Sjp161948The B<x509> command is a multi purpose certificate utility. It can be
60*2175Sjp161948used to display certificate information, convert certificates to
61*2175Sjp161948various forms, sign certificate requests like a "mini CA" or edit
62*2175Sjp161948certificate trust settings.
63*2175Sjp161948
64*2175Sjp161948Since there are a large number of options they will split up into
65*2175Sjp161948various sections.
66*2175Sjp161948
67*2175Sjp161948=head1 OPTIONS
68*2175Sjp161948
69*2175Sjp161948=head2 INPUT, OUTPUT AND GENERAL PURPOSE OPTIONS
70*2175Sjp161948
71*2175Sjp161948=over 4
72*2175Sjp161948
73*2175Sjp161948=item B<-inform DER|PEM|NET>
74*2175Sjp161948
75*2175Sjp161948This specifies the input format normally the command will expect an X509
76*2175Sjp161948certificate but this can change if other options such as B<-req> are
77*2175Sjp161948present. The DER format is the DER encoding of the certificate and PEM
78*2175Sjp161948is the base64 encoding of the DER encoding with header and footer lines
79*2175Sjp161948added. The NET option is an obscure Netscape server format that is now
80*2175Sjp161948obsolete.
81*2175Sjp161948
82*2175Sjp161948=item B<-outform DER|PEM|NET>
83*2175Sjp161948
84*2175Sjp161948This specifies the output format, the options have the same meaning as the
85*2175Sjp161948B<-inform> option.
86*2175Sjp161948
87*2175Sjp161948=item B<-in filename>
88*2175Sjp161948
89*2175Sjp161948This specifies the input filename to read a certificate from or standard input
90*2175Sjp161948if this option is not specified.
91*2175Sjp161948
92*2175Sjp161948=item B<-out filename>
93*2175Sjp161948
94*2175Sjp161948This specifies the output filename to write to or standard output by
95*2175Sjp161948default.
96*2175Sjp161948
97*2175Sjp161948=item B<-md2|-md5|-sha1|-mdc2>
98*2175Sjp161948
99*2175Sjp161948the digest to use. This affects any signing or display option that uses a message
100*2175Sjp161948digest, such as the B<-fingerprint>, B<-signkey> and B<-CA> options. If not
101*2175Sjp161948specified then SHA1 is used. If the key being used to sign with is a DSA key
102*2175Sjp161948then this option has no effect: SHA1 is always used with DSA keys.
103*2175Sjp161948
104*2175Sjp161948=item B<-engine id>
105*2175Sjp161948
106*2175Sjp161948specifying an engine (by it's unique B<id> string) will cause B<req>
107*2175Sjp161948to attempt to obtain a functional reference to the specified engine,
108*2175Sjp161948thus initialising it if needed. The engine will then be set as the default
109*2175Sjp161948for all available algorithms.
110*2175Sjp161948
111*2175Sjp161948=back
112*2175Sjp161948
113*2175Sjp161948=head2 DISPLAY OPTIONS
114*2175Sjp161948
115*2175Sjp161948Note: the B<-alias> and B<-purpose> options are also display options
116*2175Sjp161948but are described in the B<TRUST SETTINGS> section.
117*2175Sjp161948
118*2175Sjp161948=over 4
119*2175Sjp161948
120*2175Sjp161948=item B<-text>
121*2175Sjp161948
122*2175Sjp161948prints out the certificate in text form. Full details are output including the
123*2175Sjp161948public key, signature algorithms, issuer and subject names, serial number
124*2175Sjp161948any extensions present and any trust settings.
125*2175Sjp161948
126*2175Sjp161948=item B<-certopt option>
127*2175Sjp161948
128*2175Sjp161948customise the output format used with B<-text>. The B<option> argument can be
129*2175Sjp161948a single option or multiple options separated by commas. The B<-certopt> switch
130*2175Sjp161948may be also be used more than once to set multiple options. See the B<TEXT OPTIONS>
131*2175Sjp161948section for more information.
132*2175Sjp161948
133*2175Sjp161948=item B<-noout>
134*2175Sjp161948
135*2175Sjp161948this option prevents output of the encoded version of the request.
136*2175Sjp161948
137*2175Sjp161948=item B<-modulus>
138*2175Sjp161948
139*2175Sjp161948this option prints out the value of the modulus of the public key
140*2175Sjp161948contained in the certificate.
141*2175Sjp161948
142*2175Sjp161948=item B<-serial>
143*2175Sjp161948
144*2175Sjp161948outputs the certificate serial number.
145*2175Sjp161948
146*2175Sjp161948=item B<-subject_hash>
147*2175Sjp161948
148*2175Sjp161948outputs the "hash" of the certificate subject name. This is used in OpenSSL to
149*2175Sjp161948form an index to allow certificates in a directory to be looked up by subject
150*2175Sjp161948name.
151*2175Sjp161948
152*2175Sjp161948=item B<-issuer_hash>
153*2175Sjp161948
154*2175Sjp161948outputs the "hash" of the certificate issuer name.
155*2175Sjp161948
156*2175Sjp161948=item B<-hash>
157*2175Sjp161948
158*2175Sjp161948synonym for "-hash" for backward compatibility reasons.
159*2175Sjp161948
160*2175Sjp161948=item B<-subject>
161*2175Sjp161948
162*2175Sjp161948outputs the subject name.
163*2175Sjp161948
164*2175Sjp161948=item B<-issuer>
165*2175Sjp161948
166*2175Sjp161948outputs the issuer name.
167*2175Sjp161948
168*2175Sjp161948=item B<-nameopt option>
169*2175Sjp161948
170*2175Sjp161948option which determines how the subject or issuer names are displayed. The
171*2175Sjp161948B<option> argument can be a single option or multiple options separated by
172*2175Sjp161948commas.  Alternatively the B<-nameopt> switch may be used more than once to
173*2175Sjp161948set multiple options. See the B<NAME OPTIONS> section for more information.
174*2175Sjp161948
175*2175Sjp161948=item B<-email>
176*2175Sjp161948
177*2175Sjp161948outputs the email address(es) if any.
178*2175Sjp161948
179*2175Sjp161948=item B<-startdate>
180*2175Sjp161948
181*2175Sjp161948prints out the start date of the certificate, that is the notBefore date.
182*2175Sjp161948
183*2175Sjp161948=item B<-enddate>
184*2175Sjp161948
185*2175Sjp161948prints out the expiry date of the certificate, that is the notAfter date.
186*2175Sjp161948
187*2175Sjp161948=item B<-dates>
188*2175Sjp161948
189*2175Sjp161948prints out the start and expiry dates of a certificate.
190*2175Sjp161948
191*2175Sjp161948=item B<-fingerprint>
192*2175Sjp161948
193*2175Sjp161948prints out the digest of the DER encoded version of the whole certificate
194*2175Sjp161948(see digest options).
195*2175Sjp161948
196*2175Sjp161948=item B<-C>
197*2175Sjp161948
198*2175Sjp161948this outputs the certificate in the form of a C source file.
199*2175Sjp161948
200*2175Sjp161948=back
201*2175Sjp161948
202*2175Sjp161948=head2 TRUST SETTINGS
203*2175Sjp161948
204*2175Sjp161948Please note these options are currently experimental and may well change.
205*2175Sjp161948
206*2175Sjp161948A B<trusted certificate> is an ordinary certificate which has several
207*2175Sjp161948additional pieces of information attached to it such as the permitted
208*2175Sjp161948and prohibited uses of the certificate and an "alias".
209*2175Sjp161948
210*2175Sjp161948Normally when a certificate is being verified at least one certificate
211*2175Sjp161948must be "trusted". By default a trusted certificate must be stored
212*2175Sjp161948locally and must be a root CA: any certificate chain ending in this CA
213*2175Sjp161948is then usable for any purpose.
214*2175Sjp161948
215*2175Sjp161948Trust settings currently are only used with a root CA. They allow a finer
216*2175Sjp161948control over the purposes the root CA can be used for. For example a CA
217*2175Sjp161948may be trusted for SSL client but not SSL server use.
218*2175Sjp161948
219*2175Sjp161948See the description of the B<verify> utility for more information on the
220*2175Sjp161948meaning of trust settings.
221*2175Sjp161948
222*2175Sjp161948Future versions of OpenSSL will recognize trust settings on any
223*2175Sjp161948certificate: not just root CAs.
224*2175Sjp161948
225*2175Sjp161948
226*2175Sjp161948=over 4
227*2175Sjp161948
228*2175Sjp161948=item B<-trustout>
229*2175Sjp161948
230*2175Sjp161948this causes B<x509> to output a B<trusted> certificate. An ordinary
231*2175Sjp161948or trusted certificate can be input but by default an ordinary
232*2175Sjp161948certificate is output and any trust settings are discarded. With the
233*2175Sjp161948B<-trustout> option a trusted certificate is output. A trusted
234*2175Sjp161948certificate is automatically output if any trust settings are modified.
235*2175Sjp161948
236*2175Sjp161948=item B<-setalias arg>
237*2175Sjp161948
238*2175Sjp161948sets the alias of the certificate. This will allow the certificate
239*2175Sjp161948to be referred to using a nickname for example "Steve's Certificate".
240*2175Sjp161948
241*2175Sjp161948=item B<-alias>
242*2175Sjp161948
243*2175Sjp161948outputs the certificate alias, if any.
244*2175Sjp161948
245*2175Sjp161948=item B<-clrtrust>
246*2175Sjp161948
247*2175Sjp161948clears all the permitted or trusted uses of the certificate.
248*2175Sjp161948
249*2175Sjp161948=item B<-clrreject>
250*2175Sjp161948
251*2175Sjp161948clears all the prohibited or rejected uses of the certificate.
252*2175Sjp161948
253*2175Sjp161948=item B<-addtrust arg>
254*2175Sjp161948
255*2175Sjp161948adds a trusted certificate use. Any object name can be used here
256*2175Sjp161948but currently only B<clientAuth> (SSL client use), B<serverAuth>
257*2175Sjp161948(SSL server use) and B<emailProtection> (S/MIME email) are used.
258*2175Sjp161948Other OpenSSL applications may define additional uses.
259*2175Sjp161948
260*2175Sjp161948=item B<-addreject arg>
261*2175Sjp161948
262*2175Sjp161948adds a prohibited use. It accepts the same values as the B<-addtrust>
263*2175Sjp161948option.
264*2175Sjp161948
265*2175Sjp161948=item B<-purpose>
266*2175Sjp161948
267*2175Sjp161948this option performs tests on the certificate extensions and outputs
268*2175Sjp161948the results. For a more complete description see the B<CERTIFICATE
269*2175Sjp161948EXTENSIONS> section.
270*2175Sjp161948
271*2175Sjp161948=back
272*2175Sjp161948
273*2175Sjp161948=head2 SIGNING OPTIONS
274*2175Sjp161948
275*2175Sjp161948The B<x509> utility can be used to sign certificates and requests: it
276*2175Sjp161948can thus behave like a "mini CA".
277*2175Sjp161948
278*2175Sjp161948=over 4
279*2175Sjp161948
280*2175Sjp161948=item B<-signkey filename>
281*2175Sjp161948
282*2175Sjp161948this option causes the input file to be self signed using the supplied
283*2175Sjp161948private key.
284*2175Sjp161948
285*2175Sjp161948If the input file is a certificate it sets the issuer name to the
286*2175Sjp161948subject name (i.e.  makes it self signed) changes the public key to the
287*2175Sjp161948supplied value and changes the start and end dates. The start date is
288*2175Sjp161948set to the current time and the end date is set to a value determined
289*2175Sjp161948by the B<-days> option. Any certificate extensions are retained unless
290*2175Sjp161948the B<-clrext> option is supplied.
291*2175Sjp161948
292*2175Sjp161948If the input is a certificate request then a self signed certificate
293*2175Sjp161948is created using the supplied private key using the subject name in
294*2175Sjp161948the request.
295*2175Sjp161948
296*2175Sjp161948=item B<-clrext>
297*2175Sjp161948
298*2175Sjp161948delete any extensions from a certificate. This option is used when a
299*2175Sjp161948certificate is being created from another certificate (for example with
300*2175Sjp161948the B<-signkey> or the B<-CA> options). Normally all extensions are
301*2175Sjp161948retained.
302*2175Sjp161948
303*2175Sjp161948=item B<-keyform PEM|DER>
304*2175Sjp161948
305*2175Sjp161948specifies the format (DER or PEM) of the private key file used in the
306*2175Sjp161948B<-signkey> option.
307*2175Sjp161948
308*2175Sjp161948=item B<-days arg>
309*2175Sjp161948
310*2175Sjp161948specifies the number of days to make a certificate valid for. The default
311*2175Sjp161948is 30 days.
312*2175Sjp161948
313*2175Sjp161948=item B<-x509toreq>
314*2175Sjp161948
315*2175Sjp161948converts a certificate into a certificate request. The B<-signkey> option
316*2175Sjp161948is used to pass the required private key.
317*2175Sjp161948
318*2175Sjp161948=item B<-req>
319*2175Sjp161948
320*2175Sjp161948by default a certificate is expected on input. With this option a
321*2175Sjp161948certificate request is expected instead.
322*2175Sjp161948
323*2175Sjp161948=item B<-set_serial n>
324*2175Sjp161948
325*2175Sjp161948specifies the serial number to use. This option can be used with either
326*2175Sjp161948the B<-signkey> or B<-CA> options. If used in conjunction with the B<-CA>
327*2175Sjp161948option the serial number file (as specified by the B<-CAserial> or
328*2175Sjp161948B<-CAcreateserial> options) is not used.
329*2175Sjp161948
330*2175Sjp161948The serial number can be decimal or hex (if preceded by B<0x>). Negative
331*2175Sjp161948serial numbers can also be specified but their use is not recommended.
332*2175Sjp161948
333*2175Sjp161948=item B<-CA filename>
334*2175Sjp161948
335*2175Sjp161948specifies the CA certificate to be used for signing. When this option is
336*2175Sjp161948present B<x509> behaves like a "mini CA". The input file is signed by this
337*2175Sjp161948CA using this option: that is its issuer name is set to the subject name
338*2175Sjp161948of the CA and it is digitally signed using the CAs private key.
339*2175Sjp161948
340*2175Sjp161948This option is normally combined with the B<-req> option. Without the
341*2175Sjp161948B<-req> option the input is a certificate which must be self signed.
342*2175Sjp161948
343*2175Sjp161948=item B<-CAkey filename>
344*2175Sjp161948
345*2175Sjp161948sets the CA private key to sign a certificate with. If this option is
346*2175Sjp161948not specified then it is assumed that the CA private key is present in
347*2175Sjp161948the CA certificate file.
348*2175Sjp161948
349*2175Sjp161948=item B<-CAserial filename>
350*2175Sjp161948
351*2175Sjp161948sets the CA serial number file to use.
352*2175Sjp161948
353*2175Sjp161948When the B<-CA> option is used to sign a certificate it uses a serial
354*2175Sjp161948number specified in a file. This file consist of one line containing
355*2175Sjp161948an even number of hex digits with the serial number to use. After each
356*2175Sjp161948use the serial number is incremented and written out to the file again.
357*2175Sjp161948
358*2175Sjp161948The default filename consists of the CA certificate file base name with
359*2175Sjp161948".srl" appended. For example if the CA certificate file is called
360*2175Sjp161948"mycacert.pem" it expects to find a serial number file called "mycacert.srl".
361*2175Sjp161948
362*2175Sjp161948=item B<-CAcreateserial>
363*2175Sjp161948
364*2175Sjp161948with this option the CA serial number file is created if it does not exist:
365*2175Sjp161948it will contain the serial number "02" and the certificate being signed will
366*2175Sjp161948have the 1 as its serial number. Normally if the B<-CA> option is specified
367*2175Sjp161948and the serial number file does not exist it is an error.
368*2175Sjp161948
369*2175Sjp161948=item B<-extfile filename>
370*2175Sjp161948
371*2175Sjp161948file containing certificate extensions to use. If not specified then
372*2175Sjp161948no extensions are added to the certificate.
373*2175Sjp161948
374*2175Sjp161948=item B<-extensions section>
375*2175Sjp161948
376*2175Sjp161948the section to add certificate extensions from. If this option is not
377*2175Sjp161948specified then the extensions should either be contained in the unnamed
378*2175Sjp161948(default) section or the default section should contain a variable called
379*2175Sjp161948"extensions" which contains the section to use.
380*2175Sjp161948
381*2175Sjp161948=back
382*2175Sjp161948
383*2175Sjp161948=head2 NAME OPTIONS
384*2175Sjp161948
385*2175Sjp161948The B<nameopt> command line switch determines how the subject and issuer
386*2175Sjp161948names are displayed. If no B<nameopt> switch is present the default "oneline"
387*2175Sjp161948format is used which is compatible with previous versions of OpenSSL.
388*2175Sjp161948Each option is described in detail below, all options can be preceded by
389*2175Sjp161948a B<-> to turn the option off. Only the first four will normally be used.
390*2175Sjp161948
391*2175Sjp161948=over 4
392*2175Sjp161948
393*2175Sjp161948=item B<compat>
394*2175Sjp161948
395*2175Sjp161948use the old format. This is equivalent to specifying no name options at all.
396*2175Sjp161948
397*2175Sjp161948=item B<RFC2253>
398*2175Sjp161948
399*2175Sjp161948displays names compatible with RFC2253 equivalent to B<esc_2253>, B<esc_ctrl>,
400*2175Sjp161948B<esc_msb>, B<utf8>, B<dump_nostr>, B<dump_unknown>, B<dump_der>,
401*2175Sjp161948B<sep_comma_plus>, B<dn_rev> and B<sname>.
402*2175Sjp161948
403*2175Sjp161948=item B<oneline>
404*2175Sjp161948
405*2175Sjp161948a oneline format which is more readable than RFC2253. It is equivalent to
406*2175Sjp161948specifying the  B<esc_2253>, B<esc_ctrl>, B<esc_msb>, B<utf8>, B<dump_nostr>,
407*2175Sjp161948B<dump_der>, B<use_quote>, B<sep_comma_plus_spc>, B<spc_eq> and B<sname>
408*2175Sjp161948options.
409*2175Sjp161948
410*2175Sjp161948=item B<multiline>
411*2175Sjp161948
412*2175Sjp161948a multiline format. It is equivalent B<esc_ctrl>, B<esc_msb>, B<sep_multiline>,
413*2175Sjp161948B<spc_eq>, B<lname> and B<align>.
414*2175Sjp161948
415*2175Sjp161948=item B<esc_2253>
416*2175Sjp161948
417*2175Sjp161948escape the "special" characters required by RFC2253 in a field That is
418*2175Sjp161948B<,+"E<lt>E<gt>;>. Additionally B<#> is escaped at the beginning of a string
419*2175Sjp161948and a space character at the beginning or end of a string.
420*2175Sjp161948
421*2175Sjp161948=item B<esc_ctrl>
422*2175Sjp161948
423*2175Sjp161948escape control characters. That is those with ASCII values less than
424*2175Sjp1619480x20 (space) and the delete (0x7f) character. They are escaped using the
425*2175Sjp161948RFC2253 \XX notation (where XX are two hex digits representing the
426*2175Sjp161948character value).
427*2175Sjp161948
428*2175Sjp161948=item B<esc_msb>
429*2175Sjp161948
430*2175Sjp161948escape characters with the MSB set, that is with ASCII values larger than
431*2175Sjp161948127.
432*2175Sjp161948
433*2175Sjp161948=item B<use_quote>
434*2175Sjp161948
435*2175Sjp161948escapes some characters by surrounding the whole string with B<"> characters,
436*2175Sjp161948without the option all escaping is done with the B<\> character.
437*2175Sjp161948
438*2175Sjp161948=item B<utf8>
439*2175Sjp161948
440*2175Sjp161948convert all strings to UTF8 format first. This is required by RFC2253. If
441*2175Sjp161948you are lucky enough to have a UTF8 compatible terminal then the use
442*2175Sjp161948of this option (and B<not> setting B<esc_msb>) may result in the correct
443*2175Sjp161948display of multibyte (international) characters. Is this option is not
444*2175Sjp161948present then multibyte characters larger than 0xff will be represented
445*2175Sjp161948using the format \UXXXX for 16 bits and \WXXXXXXXX for 32 bits.
446*2175Sjp161948Also if this option is off any UTF8Strings will be converted to their
447*2175Sjp161948character form first.
448*2175Sjp161948
449*2175Sjp161948=item B<no_type>
450*2175Sjp161948
451*2175Sjp161948this option does not attempt to interpret multibyte characters in any
452*2175Sjp161948way. That is their content octets are merely dumped as though one octet
453*2175Sjp161948represents each character. This is useful for diagnostic purposes but
454*2175Sjp161948will result in rather odd looking output.
455*2175Sjp161948
456*2175Sjp161948=item B<show_type>
457*2175Sjp161948
458*2175Sjp161948show the type of the ASN1 character string. The type precedes the
459*2175Sjp161948field contents. For example "BMPSTRING: Hello World".
460*2175Sjp161948
461*2175Sjp161948=item B<dump_der>
462*2175Sjp161948
463*2175Sjp161948when this option is set any fields that need to be hexdumped will
464*2175Sjp161948be dumped using the DER encoding of the field. Otherwise just the
465*2175Sjp161948content octets will be displayed. Both options use the RFC2253
466*2175Sjp161948B<#XXXX...> format.
467*2175Sjp161948
468*2175Sjp161948=item B<dump_nostr>
469*2175Sjp161948
470*2175Sjp161948dump non character string types (for example OCTET STRING) if this
471*2175Sjp161948option is not set then non character string types will be displayed
472*2175Sjp161948as though each content octet represents a single character.
473*2175Sjp161948
474*2175Sjp161948=item B<dump_all>
475*2175Sjp161948
476*2175Sjp161948dump all fields. This option when used with B<dump_der> allows the
477*2175Sjp161948DER encoding of the structure to be unambiguously determined.
478*2175Sjp161948
479*2175Sjp161948=item B<dump_unknown>
480*2175Sjp161948
481*2175Sjp161948dump any field whose OID is not recognised by OpenSSL.
482*2175Sjp161948
483*2175Sjp161948=item B<sep_comma_plus>, B<sep_comma_plus_space>, B<sep_semi_plus_space>,
484*2175Sjp161948B<sep_multiline>
485*2175Sjp161948
486*2175Sjp161948these options determine the field separators. The first character is
487*2175Sjp161948between RDNs and the second between multiple AVAs (multiple AVAs are
488*2175Sjp161948very rare and their use is discouraged). The options ending in
489*2175Sjp161948"space" additionally place a space after the separator to make it
490*2175Sjp161948more readable. The B<sep_multiline> uses a linefeed character for
491*2175Sjp161948the RDN separator and a spaced B<+> for the AVA separator. It also
492*2175Sjp161948indents the fields by four characters.
493*2175Sjp161948
494*2175Sjp161948=item B<dn_rev>
495*2175Sjp161948
496*2175Sjp161948reverse the fields of the DN. This is required by RFC2253. As a side
497*2175Sjp161948effect this also reverses the order of multiple AVAs but this is
498*2175Sjp161948permissible.
499*2175Sjp161948
500*2175Sjp161948=item B<nofname>, B<sname>, B<lname>, B<oid>
501*2175Sjp161948
502*2175Sjp161948these options alter how the field name is displayed. B<nofname> does
503*2175Sjp161948not display the field at all. B<sname> uses the "short name" form
504*2175Sjp161948(CN for commonName for example). B<lname> uses the long form.
505*2175Sjp161948B<oid> represents the OID in numerical form and is useful for
506*2175Sjp161948diagnostic purpose.
507*2175Sjp161948
508*2175Sjp161948=item B<align>
509*2175Sjp161948
510*2175Sjp161948align field values for a more readable output. Only usable with
511*2175Sjp161948B<sep_multiline>.
512*2175Sjp161948
513*2175Sjp161948=item B<spc_eq>
514*2175Sjp161948
515*2175Sjp161948places spaces round the B<=> character which follows the field
516*2175Sjp161948name.
517*2175Sjp161948
518*2175Sjp161948=back
519*2175Sjp161948
520*2175Sjp161948=head2 TEXT OPTIONS
521*2175Sjp161948
522*2175Sjp161948As well as customising the name output format, it is also possible to
523*2175Sjp161948customise the actual fields printed using the B<certopt> options when
524*2175Sjp161948the B<text> option is present. The default behaviour is to print all fields.
525*2175Sjp161948
526*2175Sjp161948=over 4
527*2175Sjp161948
528*2175Sjp161948=item B<compatible>
529*2175Sjp161948
530*2175Sjp161948use the old format. This is equivalent to specifying no output options at all.
531*2175Sjp161948
532*2175Sjp161948=item B<no_header>
533*2175Sjp161948
534*2175Sjp161948don't print header information: that is the lines saying "Certificate" and "Data".
535*2175Sjp161948
536*2175Sjp161948=item B<no_version>
537*2175Sjp161948
538*2175Sjp161948don't print out the version number.
539*2175Sjp161948
540*2175Sjp161948=item B<no_serial>
541*2175Sjp161948
542*2175Sjp161948don't print out the serial number.
543*2175Sjp161948
544*2175Sjp161948=item B<no_signame>
545*2175Sjp161948
546*2175Sjp161948don't print out the signature algorithm used.
547*2175Sjp161948
548*2175Sjp161948=item B<no_validity>
549*2175Sjp161948
550*2175Sjp161948don't print the validity, that is the B<notBefore> and B<notAfter> fields.
551*2175Sjp161948
552*2175Sjp161948=item B<no_subject>
553*2175Sjp161948
554*2175Sjp161948don't print out the subject name.
555*2175Sjp161948
556*2175Sjp161948=item B<no_issuer>
557*2175Sjp161948
558*2175Sjp161948don't print out the issuer name.
559*2175Sjp161948
560*2175Sjp161948=item B<no_pubkey>
561*2175Sjp161948
562*2175Sjp161948don't print out the public key.
563*2175Sjp161948
564*2175Sjp161948=item B<no_sigdump>
565*2175Sjp161948
566*2175Sjp161948don't give a hexadecimal dump of the certificate signature.
567*2175Sjp161948
568*2175Sjp161948=item B<no_aux>
569*2175Sjp161948
570*2175Sjp161948don't print out certificate trust information.
571*2175Sjp161948
572*2175Sjp161948=item B<no_extensions>
573*2175Sjp161948
574*2175Sjp161948don't print out any X509V3 extensions.
575*2175Sjp161948
576*2175Sjp161948=item B<ext_default>
577*2175Sjp161948
578*2175Sjp161948retain default extension behaviour: attempt to print out unsupported certificate extensions.
579*2175Sjp161948
580*2175Sjp161948=item B<ext_error>
581*2175Sjp161948
582*2175Sjp161948print an error message for unsupported certificate extensions.
583*2175Sjp161948
584*2175Sjp161948=item B<ext_parse>
585*2175Sjp161948
586*2175Sjp161948ASN1 parse unsupported extensions.
587*2175Sjp161948
588*2175Sjp161948=item B<ext_dump>
589*2175Sjp161948
590*2175Sjp161948hex dump unsupported extensions.
591*2175Sjp161948
592*2175Sjp161948=item B<ca_default>
593*2175Sjp161948
594*2175Sjp161948the value used by the B<ca> utility, equivalent to B<no_issuer>, B<no_pubkey>, B<no_header>,
595*2175Sjp161948B<no_version>, B<no_sigdump> and B<no_signame>.
596*2175Sjp161948
597*2175Sjp161948=back
598*2175Sjp161948
599*2175Sjp161948=head1 EXAMPLES
600*2175Sjp161948
601*2175Sjp161948Note: in these examples the '\' means the example should be all on one
602*2175Sjp161948line.
603*2175Sjp161948
604*2175Sjp161948Display the contents of a certificate:
605*2175Sjp161948
606*2175Sjp161948 openssl x509 -in cert.pem -noout -text
607*2175Sjp161948
608*2175Sjp161948Display the certificate serial number:
609*2175Sjp161948
610*2175Sjp161948 openssl x509 -in cert.pem -noout -serial
611*2175Sjp161948
612*2175Sjp161948Display the certificate subject name:
613*2175Sjp161948
614*2175Sjp161948 openssl x509 -in cert.pem -noout -subject
615*2175Sjp161948
616*2175Sjp161948Display the certificate subject name in RFC2253 form:
617*2175Sjp161948
618*2175Sjp161948 openssl x509 -in cert.pem -noout -subject -nameopt RFC2253
619*2175Sjp161948
620*2175Sjp161948Display the certificate subject name in oneline form on a terminal
621*2175Sjp161948supporting UTF8:
622*2175Sjp161948
623*2175Sjp161948 openssl x509 -in cert.pem -noout -subject -nameopt oneline,-escmsb
624*2175Sjp161948
625*2175Sjp161948Display the certificate MD5 fingerprint:
626*2175Sjp161948
627*2175Sjp161948 openssl x509 -in cert.pem -noout -fingerprint
628*2175Sjp161948
629*2175Sjp161948Display the certificate SHA1 fingerprint:
630*2175Sjp161948
631*2175Sjp161948 openssl x509 -sha1 -in cert.pem -noout -fingerprint
632*2175Sjp161948
633*2175Sjp161948Convert a certificate from PEM to DER format:
634*2175Sjp161948
635*2175Sjp161948 openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER
636*2175Sjp161948
637*2175Sjp161948Convert a certificate to a certificate request:
638*2175Sjp161948
639*2175Sjp161948 openssl x509 -x509toreq -in cert.pem -out req.pem -signkey key.pem
640*2175Sjp161948
641*2175Sjp161948Convert a certificate request into a self signed certificate using
642*2175Sjp161948extensions for a CA:
643*2175Sjp161948
644*2175Sjp161948 openssl x509 -req -in careq.pem -extfile openssl.cnf -extensions v3_ca \
645*2175Sjp161948	-signkey key.pem -out cacert.pem
646*2175Sjp161948
647*2175Sjp161948Sign a certificate request using the CA certificate above and add user
648*2175Sjp161948certificate extensions:
649*2175Sjp161948
650*2175Sjp161948 openssl x509 -req -in req.pem -extfile openssl.cnf -extensions v3_usr \
651*2175Sjp161948	-CA cacert.pem -CAkey key.pem -CAcreateserial
652*2175Sjp161948
653*2175Sjp161948
654*2175Sjp161948Set a certificate to be trusted for SSL client use and change set its alias to
655*2175Sjp161948"Steve's Class 1 CA"
656*2175Sjp161948
657*2175Sjp161948 openssl x509 -in cert.pem -addtrust clientAuth \
658*2175Sjp161948	-setalias "Steve's Class 1 CA" -out trust.pem
659*2175Sjp161948
660*2175Sjp161948=head1 NOTES
661*2175Sjp161948
662*2175Sjp161948The PEM format uses the header and footer lines:
663*2175Sjp161948
664*2175Sjp161948 -----BEGIN CERTIFICATE-----
665*2175Sjp161948 -----END CERTIFICATE-----
666*2175Sjp161948
667*2175Sjp161948it will also handle files containing:
668*2175Sjp161948
669*2175Sjp161948 -----BEGIN X509 CERTIFICATE-----
670*2175Sjp161948 -----END X509 CERTIFICATE-----
671*2175Sjp161948
672*2175Sjp161948Trusted certificates have the lines
673*2175Sjp161948
674*2175Sjp161948 -----BEGIN TRUSTED CERTIFICATE-----
675*2175Sjp161948 -----END TRUSTED CERTIFICATE-----
676*2175Sjp161948
677*2175Sjp161948The conversion to UTF8 format used with the name options assumes that
678*2175Sjp161948T61Strings use the ISO8859-1 character set. This is wrong but Netscape
679*2175Sjp161948and MSIE do this as do many certificates. So although this is incorrect
680*2175Sjp161948it is more likely to display the majority of certificates correctly.
681*2175Sjp161948
682*2175Sjp161948The B<-fingerprint> option takes the digest of the DER encoded certificate.
683*2175Sjp161948This is commonly called a "fingerprint". Because of the nature of message
684*2175Sjp161948digests the fingerprint of a certificate is unique to that certificate and
685*2175Sjp161948two certificates with the same fingerprint can be considered to be the same.
686*2175Sjp161948
687*2175Sjp161948The Netscape fingerprint uses MD5 whereas MSIE uses SHA1.
688*2175Sjp161948
689*2175Sjp161948The B<-email> option searches the subject name and the subject alternative
690*2175Sjp161948name extension. Only unique email addresses will be printed out: it will
691*2175Sjp161948not print the same address more than once.
692*2175Sjp161948
693*2175Sjp161948=head1 CERTIFICATE EXTENSIONS
694*2175Sjp161948
695*2175Sjp161948The B<-purpose> option checks the certificate extensions and determines
696*2175Sjp161948what the certificate can be used for. The actual checks done are rather
697*2175Sjp161948complex and include various hacks and workarounds to handle broken
698*2175Sjp161948certificates and software.
699*2175Sjp161948
700*2175Sjp161948The same code is used when verifying untrusted certificates in chains
701*2175Sjp161948so this section is useful if a chain is rejected by the verify code.
702*2175Sjp161948
703*2175Sjp161948The basicConstraints extension CA flag is used to determine whether the
704*2175Sjp161948certificate can be used as a CA. If the CA flag is true then it is a CA,
705*2175Sjp161948if the CA flag is false then it is not a CA. B<All> CAs should have the
706*2175Sjp161948CA flag set to true.
707*2175Sjp161948
708*2175Sjp161948If the basicConstraints extension is absent then the certificate is
709*2175Sjp161948considered to be a "possible CA" other extensions are checked according
710*2175Sjp161948to the intended use of the certificate. A warning is given in this case
711*2175Sjp161948because the certificate should really not be regarded as a CA: however
712*2175Sjp161948it is allowed to be a CA to work around some broken software.
713*2175Sjp161948
714*2175Sjp161948If the certificate is a V1 certificate (and thus has no extensions) and
715*2175Sjp161948it is self signed it is also assumed to be a CA but a warning is again
716*2175Sjp161948given: this is to work around the problem of Verisign roots which are V1
717*2175Sjp161948self signed certificates.
718*2175Sjp161948
719*2175Sjp161948If the keyUsage extension is present then additional restraints are
720*2175Sjp161948made on the uses of the certificate. A CA certificate B<must> have the
721*2175Sjp161948keyCertSign bit set if the keyUsage extension is present.
722*2175Sjp161948
723*2175Sjp161948The extended key usage extension places additional restrictions on the
724*2175Sjp161948certificate uses. If this extension is present (whether critical or not)
725*2175Sjp161948the key can only be used for the purposes specified.
726*2175Sjp161948
727*2175Sjp161948A complete description of each test is given below. The comments about
728*2175Sjp161948basicConstraints and keyUsage and V1 certificates above apply to B<all>
729*2175Sjp161948CA certificates.
730*2175Sjp161948
731*2175Sjp161948
732*2175Sjp161948=over 4
733*2175Sjp161948
734*2175Sjp161948=item B<SSL Client>
735*2175Sjp161948
736*2175Sjp161948The extended key usage extension must be absent or include the "web client
737*2175Sjp161948authentication" OID.  keyUsage must be absent or it must have the
738*2175Sjp161948digitalSignature bit set. Netscape certificate type must be absent or it must
739*2175Sjp161948have the SSL client bit set.
740*2175Sjp161948
741*2175Sjp161948=item B<SSL Client CA>
742*2175Sjp161948
743*2175Sjp161948The extended key usage extension must be absent or include the "web client
744*2175Sjp161948authentication" OID. Netscape certificate type must be absent or it must have
745*2175Sjp161948the SSL CA bit set: this is used as a work around if the basicConstraints
746*2175Sjp161948extension is absent.
747*2175Sjp161948
748*2175Sjp161948=item B<SSL Server>
749*2175Sjp161948
750*2175Sjp161948The extended key usage extension must be absent or include the "web server
751*2175Sjp161948authentication" and/or one of the SGC OIDs.  keyUsage must be absent or it
752*2175Sjp161948must have the digitalSignature, the keyEncipherment set or both bits set.
753*2175Sjp161948Netscape certificate type must be absent or have the SSL server bit set.
754*2175Sjp161948
755*2175Sjp161948=item B<SSL Server CA>
756*2175Sjp161948
757*2175Sjp161948The extended key usage extension must be absent or include the "web server
758*2175Sjp161948authentication" and/or one of the SGC OIDs.  Netscape certificate type must
759*2175Sjp161948be absent or the SSL CA bit must be set: this is used as a work around if the
760*2175Sjp161948basicConstraints extension is absent.
761*2175Sjp161948
762*2175Sjp161948=item B<Netscape SSL Server>
763*2175Sjp161948
764*2175Sjp161948For Netscape SSL clients to connect to an SSL server it must have the
765*2175Sjp161948keyEncipherment bit set if the keyUsage extension is present. This isn't
766*2175Sjp161948always valid because some cipher suites use the key for digital signing.
767*2175Sjp161948Otherwise it is the same as a normal SSL server.
768*2175Sjp161948
769*2175Sjp161948=item B<Common S/MIME Client Tests>
770*2175Sjp161948
771*2175Sjp161948The extended key usage extension must be absent or include the "email
772*2175Sjp161948protection" OID. Netscape certificate type must be absent or should have the
773*2175Sjp161948S/MIME bit set. If the S/MIME bit is not set in netscape certificate type
774*2175Sjp161948then the SSL client bit is tolerated as an alternative but a warning is shown:
775*2175Sjp161948this is because some Verisign certificates don't set the S/MIME bit.
776*2175Sjp161948
777*2175Sjp161948=item B<S/MIME Signing>
778*2175Sjp161948
779*2175Sjp161948In addition to the common S/MIME client tests the digitalSignature bit must
780*2175Sjp161948be set if the keyUsage extension is present.
781*2175Sjp161948
782*2175Sjp161948=item B<S/MIME Encryption>
783*2175Sjp161948
784*2175Sjp161948In addition to the common S/MIME tests the keyEncipherment bit must be set
785*2175Sjp161948if the keyUsage extension is present.
786*2175Sjp161948
787*2175Sjp161948=item B<S/MIME CA>
788*2175Sjp161948
789*2175Sjp161948The extended key usage extension must be absent or include the "email
790*2175Sjp161948protection" OID. Netscape certificate type must be absent or must have the
791*2175Sjp161948S/MIME CA bit set: this is used as a work around if the basicConstraints
792*2175Sjp161948extension is absent.
793*2175Sjp161948
794*2175Sjp161948=item B<CRL Signing>
795*2175Sjp161948
796*2175Sjp161948The keyUsage extension must be absent or it must have the CRL signing bit
797*2175Sjp161948set.
798*2175Sjp161948
799*2175Sjp161948=item B<CRL Signing CA>
800*2175Sjp161948
801*2175Sjp161948The normal CA tests apply. Except in this case the basicConstraints extension
802*2175Sjp161948must be present.
803*2175Sjp161948
804*2175Sjp161948=back
805*2175Sjp161948
806*2175Sjp161948=head1 BUGS
807*2175Sjp161948
808*2175Sjp161948Extensions in certificates are not transferred to certificate requests and
809*2175Sjp161948vice versa.
810*2175Sjp161948
811*2175Sjp161948It is possible to produce invalid certificates or requests by specifying the
812*2175Sjp161948wrong private key or using inconsistent options in some cases: these should
813*2175Sjp161948be checked.
814*2175Sjp161948
815*2175Sjp161948There should be options to explicitly set such things as start and end
816*2175Sjp161948dates rather than an offset from the current time.
817*2175Sjp161948
818*2175Sjp161948The code to implement the verify behaviour described in the B<TRUST SETTINGS>
819*2175Sjp161948is currently being developed. It thus describes the intended behaviour rather
820*2175Sjp161948than the current behaviour. It is hoped that it will represent reality in
821*2175Sjp161948OpenSSL 0.9.5 and later.
822*2175Sjp161948
823*2175Sjp161948=head1 SEE ALSO
824*2175Sjp161948
825*2175Sjp161948L<req(1)|req(1)>, L<ca(1)|ca(1)>, L<genrsa(1)|genrsa(1)>,
826*2175Sjp161948L<gendsa(1)|gendsa(1)>, L<verify(1)|verify(1)>
827*2175Sjp161948
828*2175Sjp161948=head1 HISTORY
829*2175Sjp161948
830*2175Sjp161948Before OpenSSL 0.9.8, the default digest for RSA keys was MD5.
831*2175Sjp161948
832*2175Sjp161948=cut
833