Don't request client certificate in anonymous ciphersuites
[openssl.git] / doc / man / req.pod
1
2 =pod
3
4 =head1 NAME
5
6 req - PKCS#10 certificate and certificate generating utility.
7
8 =head1 SYNOPSIS
9
10 B<openssl> B<req>
11 [B<-inform PEM|DER>]
12 [B<-outform PEM|DER>]
13 [B<-in filename>]
14 [B<-out filename>]
15 [B<-text>]
16 [B<-noout>]
17 [B<-verify>]
18 [B<-modulus>]
19 [B<-new>]
20 [B<-newkey rsa:bits>]
21 [B<-newkey dsa:file>]
22 [B<-nodes>]
23 [B<-key filename>]
24 [B<-keyform PEM|DER>]
25 [B<-keyout filename>]
26 [B<-[md5|sha1|md2|mdc2]>]
27 [B<-config filename>]
28 [B<-x509>]
29 [B<-days n>]
30 [B<-noasn1-kludge>]
31 [B<-extensions section>]
32 [B<-reqexts section>]
33
34 =head1 DESCRIPTION
35
36 The B<req> command primarily creates and processes certificate requests
37 in PKCS#10 format. It can additionally create self signed certificates
38 for use as root CAs for example.
39
40 =head1 COMMAND OPTIONS
41
42 =over 4
43
44 =item B<-inform DER|PEM>
45
46 This specifies the input format. The B<DER> option uses an ASN1 DER encoded
47 form compatible with the PKCS#10. The B<PEM> form is the default format: it
48 consists of the B<DER> format base64 encoded with additional header and
49 footer lines.
50
51 =item B<-outform DER|PEM>
52
53 This specifies the output format, the options have the same meaning as the 
54 B<-inform> option.
55
56 =item B<-in filename>
57
58 This specifies the input filename to read a request from or standard input
59 if this option is not specified. A request is only read if the creation
60 options (B<-new> and B<-newkey>) are not specified.
61
62 =item B<-out filename>
63
64 This specifies the output filename to write to or standard output by
65 default.
66
67 =item B<-text>
68
69 prints out the certificate request in text form.
70
71 =item B<-noout>
72
73 this option prevents output of the encoded version of the request.
74
75 =item B<-modulus>
76
77 this option prints out the value of the modulus of the public key
78 contained in the request.
79
80 =item B<-verify>
81
82 verifies the signature on the request.
83
84 =item B<-new>
85
86 this option generates a new certificate request. It will prompt
87 the user for the relevant field values. The actual fields
88 prompted for and their maximum and minimum sizes are specified
89 in the configuration file and any requested extensions.
90
91 If the B<-key> option is not used it will generate a new RSA private
92 key using information specified in the configuration file.
93
94 =item B<-newkey arg>
95
96 this option creates a new certificate request and a new private
97 key. The argument takes one of two forms. B<rsa:nbits>, where
98 B<nbits> is the number of bits, generates an RSA key B<nbits>
99 in size. B<dsa:filename> generates a DSA key using the parameters
100 in the file B<filename>.
101
102 =item B<-key filename>
103
104 This specifies the file to read the private key from. It also
105 accepts PKCS#8 format private keys for PEM format files.
106
107 =item B<-keyform PEM|DER>
108
109 the format of the private key file specified in the B<-key>
110 argument. PEM is the default.
111
112 =item B<-keyout filename>
113
114 this gives the filename to write the newly created private key to.
115 If this option is not specified then the filename present in the
116 configuration file is used.
117
118 =item B<-nodes>
119
120 if this option is specified then if a private key is created it
121 will not be encrypted.
122
123 =item B<-[md5|sha1|md2|mdc2]>
124
125 this specifies the message digest to sign the request with. This
126 overrides the digest algorithm specified in the configuration file.
127 This option is ignore for DSA requests: they always use SHA1.
128
129 =item B<-config filename>
130
131 this allows an alternative configuration file to be specified,
132 this overrides the compile time filename or any specified in
133 the B<OPENSSL_CONF> environment variable.
134
135 =item B<-x509>
136
137 this option outputs a self signed certificate instead of a certificate
138 request. This is typically used to generate a test certificate or
139 a self signed root CA. The extensions added to the certificate
140 (if any) are specified in the configuration file.
141
142 =item B<-days n>
143
144 when the B<-x509> option is being used this specifies the number of
145 days to certify the certificate for. The default is 30 days.
146
147 =item B<-extensions section>
148 =item B<-reqexts section>
149
150 these options specify alternative sections to include certificate
151 extensions (if the B<-x509> option is present) or certificate
152 request extensions. This allows several different sections to
153 be used in the same configuration file to specify requests for
154 a variety of purposes.
155
156 =item B<-asn1-kludge>
157
158 by default the B<req> command outputs certificate requests containing
159 no attributes in the correct PKCS#10 format. However certain CAs will only
160 accept requests containing no attributes in an invalid form: this
161 option produces this invalid format.
162
163 More precisely the B<Attributes> in a PKCS#10 certificate request
164 are defined as a B<SET OF Attribute>. They are B<not OPTIONAL> so
165 if no attributes are present then they should be encoded as an
166 empty B<SET OF>. The invalid form does not include the empty
167 B<SET OF> whereas the correct form does.
168
169 It should be noted that very few CAs still require the use of this option.
170
171 =back
172
173 =head1 CONFIGURATION FILE FORMAT
174
175 The configuation options are specified in the B<req> section of
176 the configuration file. As with all configuration files if no
177 value is specified in the specific section (i.e. B<req>) then
178 the initial unnamed or B<default> section is searched too.
179
180 The options available are described in detail below.
181
182 =over 4
183
184 =item B<default_bits>
185
186 This specifies the default key size in bits. If not specified then
187 512 is used. It is used if the B<-new> option is used. It can be
188 overriden by using the B<-newkey> option.
189
190 =item B<default_keyfile>
191
192 This is the default filename to write a private key to. If not
193 specified the key is written to standard output. This can be
194 overriden by the B<-keyout> option.
195
196 =item B<oid_file>
197
198 This specifies a file containing additional B<OBJECT IDENTIFIERS>.
199 Each line of the file should consist of the numerical form of the
200 object identifier followed by white space then the short name followed
201 by white space and finally the long name. 
202
203 =item B<oid_section>
204
205 This specifies a section in the configuration file containing extra
206 object identifiers. Each line should consist of the short name of the
207 object identifier followed by B<=> and the numerical form. The short
208 and long names are the same when this option is used.
209
210 =item B<RANDFILE>
211
212 This specifies a filename in which random number seed information is
213 placed and read from. It is used for private key generation.
214
215 =item B<encrypt_rsa_key|encrypt_key>
216
217 If this is set to B<no> then if a private key is generated it is
218 B<not> encrypted. This is equivalent to the B<-nodes> command line
219 option.
220
221 =item B<default_md>
222
223 This option specifies the digest algorithm to use. Possible values
224 include B<md5 sha1 mdc2>. If not present then MD5 is used. This
225 option can be overridden on the command line.
226
227 =item B<dirstring_type>
228
229 This option specifies which string types are permissible in a
230 B<DirectoryString>. Most users will not need to change this option.
231
232 It can be set to several values B<default> which is also the default
233 option uses PrintableStrings, T61Strings and BMPStrings if the 
234 B<pkix> value is used then only PrintableStrings and BMPStrings will
235 be used. This follows the PKIX recommendation in RFC2459. If the
236 B<utf8only> option is used then only UTF8Strings will be used: this
237 is the PKIX recommendation in RFC2459 after 2003. Finally the B<nobmp>
238 option just uses PrintableStrings and T61Strings: certain software has
239 problems with BMPStrings.
240
241 =item B<req_extensions>
242
243 this specifies the configuration file section containing a list of
244 extensions to add to the certificate request. It can be overridden
245 by the B<-reqexts> command line switch.
246
247 =item B<x509_extensions>
248
249 this specifies the configuration file section containing a list of
250 extensions to add to certificate generated when the B<-x509> switch
251 is used. It can be overridden by the B<-extensions> command line switch.
252
253 =item B<attributes>
254
255 this specifies the section containing any request attributes: its format
256 is the same as B<distinguished_name> described below. Typically these
257 may contain the challengePassword or unstructuredName types. They are
258 currently ignored by OpenSSLs request signing utilities but some CAs might want
259 want them.
260
261 =item B<distinguished_name>
262
263 This specifies the section containing the distiguished name fields to
264 prompt for when generating a certificate or certificate request. This
265 consists of lines of the form:
266
267         fieldName="prompt"
268         fieldName_default="default field value"
269         fieldName_min= 2
270         fieldName_max= 4
271
272 "fieldName" is the field name being used, for example commonName.
273 The "prompt" string is used to ask the user to enter the relvant
274 details. If the user enters nothing then the default value is used if no
275 default value is present then the field is omitted. A field can
276 still be omitted if a default value is present if the user just
277 enters the '.' character.
278
279 The number of characters entered must be between the fieldName_min and
280 fieldName_max limits: there may be additional restrictions based
281 on the field being used (for example countryName can only ever be
282 two characters long and must fit in a PrintableString).
283
284 Some fields (such as organizationName) can be used more than once
285 in a DN. This presents a problem because configuration files will
286 not recognise the same name occurring twice. To avoid this problem
287 if the fieldName contains an some characters followed by a full stop
288 they will be ignored. So for example a second organizationName can
289 be input by calling it "1.organizationName".
290
291 The actual permitted field names are any object identifier short or
292 long names. These are compiled into OpenSSL and include the usual
293 values such as commonName, countryName, localityName, organizationName,
294 organizationUnitName, stateOrPrivinceName. Additionally emailAddress
295 is include as well as name, surname, givenName initials and dnQualifier
296 are supported.
297
298 Additional object identifiers can be defined with the B<oid_file> or
299 B<oid_section> options in the configuration file. Any additional fields
300 will be treated as though they were a DirectoryString.
301
302 =back
303
304 =head1 EXAMPLES
305
306 Examine and verify certificate request:
307
308  openssl req -in req.pem -text -verify -noout
309
310 Create a private key and then generate a certificate request from it:
311
312  openssl genrsa -out key.pem 1024
313  openssl req -new -key key.pem -out req.pem
314
315 The same but just using req:
316
317  openssl req -newkey rsa:1024 -keyout key.pem -out req.pem
318
319 Generate a self signed root certificate:
320
321  openssl req -x509 -newkey rsa:1024 -keyout key.pem -out req.pem
322
323 Example of a file pointed to by the B<oid_file> option:
324
325  1.2.3.4        shortName       A longer Name
326  1.2.3.6        otherName       Other longer Name
327
328 Example of a section pointed to by B<oid_section> making use of variable
329 expansion:
330
331  testoid1=1.2.3.5
332  testoid2=${testoid1}.6
333
334 Sample configuration file:
335
336  [ req ]
337  default_bits           = 1024
338  default_keyfile        = privkey.pem
339  distinguished_name     = req_distinguished_name
340  attributes             = req_attributes
341  x509_extensions        = v3_ca
342
343  dirstring_type = nobmp
344
345  [ req_distinguished_name ]
346  countryName                    = Country Name (2 letter code)
347  countryName_default            = AU
348  countryName_min                        = 2
349  countryName_max                        = 2
350
351  localityName                   = Locality Name (eg, city)
352
353  organizationalUnitName         = Organizational Unit Name (eg, section)
354
355  commonName                     = Common Name (eg, YOUR name)
356  commonName_max                 = 64
357
358  emailAddress                   = Email Address
359  emailAddress_max               = 40
360
361  [ req_attributes ]
362  challengePassword              = A challenge password
363  challengePassword_min          = 4
364  challengePassword_max          = 20
365
366  [ v3_ca ]
367
368  subjectKeyIdentifier=hash
369  authorityKeyIdentifier=keyid:always,issuer:always
370  basicConstraints = CA:true
371
372 =head1 NOTES
373
374 The header and footer lines in the B<PEM> format are respectively:
375
376  -----BEGIN CERTIFICATE REQUEST----
377  -----END CERTIFICATE REQUEST----
378
379 some software (some versions of Netscape certificate server) instead needs:
380
381  -----BEGIN NEW CERTIFICATE REQUEST----
382  -----END NEW CERTIFICATE REQUEST----
383
384 but is otherwise compatible. Either form is accepted on input.
385
386 The certificate requests generated by B<Xenroll> with MSIE have extensions
387 added. It includes the B<keyUsage> extension which determines the type of
388 key (signature only or general purpose) and any additional OIDs entered
389 by the script in an extendedKeyUsage extension.
390
391 =head1 DIAGNOSTICS
392
393 The following messages are frequently asked about:
394
395         Using configuration from /some/path/openssl.cnf
396         Unable to load config info
397
398 This is followed some time later by...
399
400         unable to find 'distinguished_name' in config
401         problems making Certificate Request
402
403 The first error message is the clue: it can't find the configuration
404 file! Certain operations (like examining a certificate request) don't
405 need a configuration file so its use isn't enforced. Generation of
406 certficates or requests however does need a configuration file. This
407 could be regarded as a bug.
408
409 Another puzzling message is this:
410
411         Attributes:
412             a0:00
413
414 this is displayed when no attributes are present and the request includes
415 the correct empty B<SET OF> structure (the DER encoding of which is 0xa0
416 0x00). If you just see:
417
418         Attributes:
419
420 then the B<SET OF> is missing and the encoding is technically invalid (but
421 it is tolerated). See the description of the command line option B<-asn1-kludge>
422 for more information.
423
424 =head1 ENVIRONMENT VARIABLES
425
426 The variable B<OPENSSL_CONF> if defined allows an alternative configuration
427 file location to be specified, it will be overridden by the B<-config> command
428 line switch if it is present. For compatability reasons the B<SSLEAY_CONF>
429 environment variable serves the same purpose but its use is discouraged.
430
431 =head1 BUGS
432
433 OpenSSLs handling of T61Strings (aka TeletexStrings) is broken: it effectively
434 treats them as ISO-8859-1 (latin 1), Netscape and MSIE have similar behaviour.
435 This can cause problems if you need characters that aren't available in
436 PrintableStrings and you don't want to or can't use BMPStrings.
437
438 As a consequence of the T61String handling the only correct way to represent
439 accented characters in OpenSSL is to use a BMPString: unfortunately Netscape
440 currently chokes on these. If you have to use accented characters with Netscape
441 and MSIE then you currently need to use the invalid T61String form.
442
443 The current prompting is not very friendly. It exits if you get the strings
444 wrong and doesn't allow you to confirm what you've just entered. Other things
445 like extensions in certificate requests are statically defined in the configuration
446 file. Some of these: like an email address in subjectAltName should be input
447 by the user.
448
449 There should be a way to have a friendly front end (e.g. perl script or GUI)
450 handle all user input and then just feed a "template" file into B<req> which
451 then silently creates the request or certificate. This would also shift the
452 responsibility for handling such problems as internationalisation of characters
453 onto the front end: the template could then just expect valid UTF8 character
454 strings for example.
455
456 =head1 SEE ALSO
457
458 x509(1), ca(1), genrsa(1), gendsa(1), config(5)
459
460 =cut