1REQ(1) OpenSSL REQ(1)
2
3
4
6 req - PKCS#10 certificate request and certificate generating utility.
7
9 openssl req [-inform PEM|DER] [-outform PEM|DER] [-in filename]
10 [-passin arg] [-out filename] [-passout arg] [-text] [-pubkey] [-noout]
11 [-verify] [-modulus] [-new] [-rand file(s)] [-newkey rsa:bits] [-newkey
12 alg:file] [-nodes] [-key filename] [-keyform PEM|DER] [-keyout
13 filename] [-keygen_engine id] [-[digest]] [-config filename] [-subj
14 arg] [-multivalue-rdn] [-x509] [-days n] [-set_serial n] [-asn1-kludge]
15 [-no-asn1-kludge] [-newhdr] [-extensions section] [-reqexts section]
16 [-utf8] [-nameopt] [-reqopt] [-subject] [-subj arg] [-batch] [-verbose]
17 [-engine id]
18
20 The req command primarily creates and processes certificate requests in
21 PKCS#10 format. It can additionally create self signed certificates for
22 use as root CAs for example.
23
25 -inform DER|PEM
26 This specifies the input format. The DER option uses an ASN1 DER
27 encoded form compatible with the PKCS#10. The PEM form is the
28 default format: it consists of the DER format base64 encoded with
29 additional header and footer lines.
30
31 -outform DER|PEM
32 This specifies the output format, the options have the same meaning
33 as the -inform option.
34
35 -in filename
36 This specifies the input filename to read a request from or
37 standard input if this option is not specified. A request is only
38 read if the creation options (-new and -newkey) are not specified.
39
40 -passin arg
41 the input file password source. For more information about the
42 format of arg see the PASS PHRASE ARGUMENTS section in openssl(1).
43
44 -out filename
45 This specifies the output filename to write to or standard output
46 by default.
47
48 -passout arg
49 the output file password source. For more information about the
50 format of arg see the PASS PHRASE ARGUMENTS section in openssl(1).
51
52 -text
53 prints out the certificate request in text form.
54
55 -subject
56 prints out the request subject (or certificate subject if -x509 is
57 specified)
58
59 -pubkey
60 outputs the public key.
61
62 -noout
63 this option prevents output of the encoded version of the request.
64
65 -modulus
66 this option prints out the value of the modulus of the public key
67 contained in the request.
68
69 -verify
70 verifies the signature on the request.
71
72 -new
73 this option generates a new certificate request. It will prompt the
74 user for the relevant field values. The actual fields prompted for
75 and their maximum and minimum sizes are specified in the
76 configuration file and any requested extensions.
77
78 If the -key option is not used it will generate a new RSA private
79 key using information specified in the configuration file.
80
81 -subj arg
82 Replaces subject field of input request with specified data and
83 outputs modified request. The arg must be formatted as
84 /type0=value0/type1=value1/type2=..., characters may be escaped by
85 \ (backslash), no spaces are skipped.
86
87 -rand file(s)
88 a file or files containing random data used to seed the random
89 number generator, or an EGD socket (see RAND_egd(3)). Multiple
90 files can be specified separated by a OS-dependent character. The
91 separator is ; for MS-Windows, , for OpenVMS, and : for all others.
92
93 -newkey arg
94 this option creates a new certificate request and a new private
95 key. The argument takes one of several forms. rsa:nbits, where
96 nbits is the number of bits, generates an RSA key nbits in size. If
97 nbits is omitted, i.e. -newkey rsa specified, the default key size,
98 specified in the configuration file is used.
99
100 All other algorithms support the -newkey alg:file form, where file
101 may be an algorithm parameter file, created by the genpkey
102 -genparam command or and X.509 certificate for a key with
103 approriate algorithm.
104
105 param:file generates a key using the parameter file or certificate
106 file, the algorithm is determined by the parameters. algname:file
107 use algorithm algname and parameter file file: the two algorithms
108 must match or an error occurs. algname just uses algorithm algname,
109 and parameters, if neccessary should be specified via -pkeyopt
110 parameter.
111
112 dsa:filename generates a DSA key using the parameters in the file
113 filename. ec:filename generates EC key (usable both with ECDSA or
114 ECDH algorithms), gost2001:filename generates GOST R 34.10-2001 key
115 (requires ccgost engine configured in the configuration file). If
116 just gost2001 is specified a parameter set should be specified by
117 -pkeyopt paramset:X
118
119 -pkeyopt opt:value
120 set the public key algorithm option opt to value. The precise set
121 of options supported depends on the public key algorithm used and
122 its implementation. See KEY GENERATION OPTIONS in the genpkey
123 manual page for more details.
124
125 -key filename
126 This specifies the file to read the private key from. It also
127 accepts PKCS#8 format private keys for PEM format files.
128
129 -keyform PEM|DER
130 the format of the private key file specified in the -key argument.
131 PEM is the default.
132
133 -keyout filename
134 this gives the filename to write the newly created private key to.
135 If this option is not specified then the filename present in the
136 configuration file is used.
137
138 -nodes
139 if this option is specified then if a private key is created it
140 will not be encrypted.
141
142 -[digest]
143 this specifies the message digest to sign the request with (such as
144 -md5, -sha1). This overrides the digest algorithm specified in the
145 configuration file. For full list of possible digests see openssl
146 dgst -h output.
147
148 Some public key algorithms may override this choice. For instance,
149 DSA signatures always use SHA1, GOST R 34.10 signatures always use
150 GOST R 34.11-94 (-md_gost94).
151
152 -config filename
153 this allows an alternative configuration file to be specified, this
154 overrides the compile time filename or any specified in the
155 OPENSSL_CONF environment variable.
156
157 -subj arg
158 sets subject name for new request or supersedes the subject name
159 when processing a request. The arg must be formatted as
160 /type0=value0/type1=value1/type2=..., characters may be escaped by
161 \ (backslash), no spaces are skipped.
162
163 -multivalue-rdn
164 this option causes the -subj argument to be interpreted with full
165 support for multivalued RDNs. Example:
166
167 /DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe
168
169 If -multi-rdn is not used then the UID value is 123456+CN=John Doe.
170
171 -x509
172 this option outputs a self signed certificate instead of a
173 certificate request. This is typically used to generate a test
174 certificate or a self signed root CA. The extensions added to the
175 certificate (if any) are specified in the configuration file.
176 Unless specified using the set_serial option 0 will be used for the
177 serial number.
178
179 -days n
180 when the -x509 option is being used this specifies the number of
181 days to certify the certificate for. The default is 30 days.
182
183 -set_serial n
184 serial number to use when outputting a self signed certificate.
185 This may be specified as a decimal value or a hex value if preceded
186 by 0x. It is possible to use negative serial numbers but this is
187 not recommended.
188
189 -extensions section
190 -reqexts section
191 these options specify alternative sections to include certificate
192 extensions (if the -x509 option is present) or certificate request
193 extensions. This allows several different sections to be used in
194 the same configuration file to specify requests for a variety of
195 purposes.
196
197 -utf8
198 this option causes field values to be interpreted as UTF8 strings,
199 by default they are interpreted as ASCII. This means that the field
200 values, whether prompted from a terminal or obtained from a
201 configuration file, must be valid UTF8 strings.
202
203 -nameopt option
204 option which determines how the subject or issuer names are
205 displayed. The option argument can be a single option or multiple
206 options separated by commas. Alternatively the -nameopt switch may
207 be used more than once to set multiple options. See the x509(1)
208 manual page for details.
209
210 -reqopt
211 customise the output format used with -text. The option argument
212 can be a single option or multiple options separated by commas.
213
214 See discission of the -certopt parameter in the x509 command.
215
216 -asn1-kludge
217 by default the req command outputs certificate requests containing
218 no attributes in the correct PKCS#10 format. However certain CAs
219 will only accept requests containing no attributes in an invalid
220 form: this option produces this invalid format.
221
222 More precisely the Attributes in a PKCS#10 certificate request are
223 defined as a SET OF Attribute. They are not OPTIONAL so if no
224 attributes are present then they should be encoded as an empty SET
225 OF. The invalid form does not include the empty SET OF whereas the
226 correct form does.
227
228 It should be noted that very few CAs still require the use of this
229 option.
230
231 -no-asn1-kludge
232 Reverses effect of -asn1-kludge
233
234 -newhdr
235 Adds the word NEW to the PEM file header and footer lines on the
236 outputed request. Some software (Netscape certificate server) and
237 some CAs need this.
238
239 -batch
240 non-interactive mode.
241
242 -verbose
243 print extra details about the operations being performed.
244
245 -engine id
246 specifying an engine (by its unique id string) will cause req to
247 attempt to obtain a functional reference to the specified engine,
248 thus initialising it if needed. The engine will then be set as the
249 default for all available algorithms.
250
251 -keygen_engine id
252 specifies an engine (by its unique id string) which would be used
253 for key generation operations.
254
256 The configuration options are specified in the req section of the
257 configuration file. As with all configuration files if no value is
258 specified in the specific section (i.e. req) then the initial unnamed
259 or default section is searched too.
260
261 The options available are described in detail below.
262
263 input_password output_password
264 The passwords for the input private key file (if present) and the
265 output private key file (if one will be created). The command line
266 options passin and passout override the configuration file values.
267
268 default_bits
269 This specifies the default key size in bits. If not specified then
270 512 is used. It is used if the -new option is used. It can be
271 overridden by using the -newkey option.
272
273 default_keyfile
274 This is the default filename to write a private key to. If not
275 specified the key is written to standard output. This can be
276 overridden by the -keyout option.
277
278 oid_file
279 This specifies a file containing additional OBJECT IDENTIFIERS.
280 Each line of the file should consist of the numerical form of the
281 object identifier followed by white space then the short name
282 followed by white space and finally the long name.
283
284 oid_section
285 This specifies a section in the configuration file containing extra
286 object identifiers. Each line should consist of the short name of
287 the object identifier followed by = and the numerical form. The
288 short and long names are the same when this option is used.
289
290 RANDFILE
291 This specifies a filename in which random number seed information
292 is placed and read from, or an EGD socket (see RAND_egd(3)). It is
293 used for private key generation.
294
295 encrypt_key
296 If this is set to no then if a private key is generated it is not
297 encrypted. This is equivalent to the -nodes command line option.
298 For compatibility encrypt_rsa_key is an equivalent option.
299
300 default_md
301 This option specifies the digest algorithm to use. Possible values
302 include md5 sha1 mdc2. If not present then MD5 is used. This option
303 can be overridden on the command line.
304
305 string_mask
306 This option masks out the use of certain string types in certain
307 fields. Most users will not need to change this option.
308
309 It can be set to several values default which is also the default
310 option uses PrintableStrings, T61Strings and BMPStrings if the pkix
311 value is used then only PrintableStrings and BMPStrings will be
312 used. This follows the PKIX recommendation in RFC2459. If the
313 utf8only option is used then only UTF8Strings will be used: this is
314 the PKIX recommendation in RFC2459 after 2003. Finally the nombstr
315 option just uses PrintableStrings and T61Strings: certain software
316 has problems with BMPStrings and UTF8Strings: in particular
317 Netscape.
318
319 req_extensions
320 this specifies the configuration file section containing a list of
321 extensions to add to the certificate request. It can be overridden
322 by the -reqexts command line switch. See the x509v3_config(5)
323 manual page for details of the extension section format.
324
325 x509_extensions
326 this specifies the configuration file section containing a list of
327 extensions to add to certificate generated when the -x509 switch is
328 used. It can be overridden by the -extensions command line switch.
329
330 prompt
331 if set to the value no this disables prompting of certificate
332 fields and just takes values from the config file directly. It also
333 changes the expected format of the distinguished_name and
334 attributes sections.
335
336 utf8
337 if set to the value yes then field values to be interpreted as UTF8
338 strings, by default they are interpreted as ASCII. This means that
339 the field values, whether prompted from a terminal or obtained from
340 a configuration file, must be valid UTF8 strings.
341
342 attributes
343 this specifies the section containing any request attributes: its
344 format is the same as distinguished_name. Typically these may
345 contain the challengePassword or unstructuredName types. They are
346 currently ignored by OpenSSL's request signing utilities but some
347 CAs might want them.
348
349 distinguished_name
350 This specifies the section containing the distinguished name fields
351 to prompt for when generating a certificate or certificate request.
352 The format is described in the next section.
353
355 There are two separate formats for the distinguished name and attribute
356 sections. If the prompt option is set to no then these sections just
357 consist of field names and values: for example,
358
359 CN=My Name
360 OU=My Organization
361 emailAddress=someone@somewhere.org
362
363 This allows external programs (e.g. GUI based) to generate a template
364 file with all the field names and values and just pass it to req. An
365 example of this kind of configuration file is contained in the EXAMPLES
366 section.
367
368 Alternatively if the prompt option is absent or not set to no then the
369 file contains field prompting information. It consists of lines of the
370 form:
371
372 fieldName="prompt"
373 fieldName_default="default field value"
374 fieldName_min= 2
375 fieldName_max= 4
376
377 "fieldName" is the field name being used, for example commonName (or
378 CN). The "prompt" string is used to ask the user to enter the relevant
379 details. If the user enters nothing then the default value is used if
380 no default value is present then the field is omitted. A field can
381 still be omitted if a default value is present if the user just enters
382 the '.' character.
383
384 The number of characters entered must be between the fieldName_min and
385 fieldName_max limits: there may be additional restrictions based on the
386 field being used (for example countryName can only ever be two
387 characters long and must fit in a PrintableString).
388
389 Some fields (such as organizationName) can be used more than once in a
390 DN. This presents a problem because configuration files will not
391 recognize the same name occurring twice. To avoid this problem if the
392 fieldName contains some characters followed by a full stop they will be
393 ignored. So for example a second organizationName can be input by
394 calling it "1.organizationName".
395
396 The actual permitted field names are any object identifier short or
397 long names. These are compiled into OpenSSL and include the usual
398 values such as commonName, countryName, localityName, organizationName,
399 organizationUnitName, stateOrProvinceName. Additionally emailAddress is
400 include as well as name, surname, givenName initials and dnQualifier.
401
402 Additional object identifiers can be defined with the oid_file or
403 oid_section options in the configuration file. Any additional fields
404 will be treated as though they were a DirectoryString.
405
407 Examine and verify certificate request:
408
409 openssl req -in req.pem -text -verify -noout
410
411 Create a private key and then generate a certificate request from it:
412
413 openssl genrsa -out key.pem 1024
414 openssl req -new -key key.pem -out req.pem
415
416 The same but just using req:
417
418 openssl req -newkey rsa:1024 -keyout key.pem -out req.pem
419
420 Generate a self signed root certificate:
421
422 openssl req -x509 -newkey rsa:1024 -keyout key.pem -out req.pem
423
424 Example of a file pointed to by the oid_file option:
425
426 1.2.3.4 shortName A longer Name
427 1.2.3.6 otherName Other longer Name
428
429 Example of a section pointed to by oid_section making use of variable
430 expansion:
431
432 testoid1=1.2.3.5
433 testoid2=${testoid1}.6
434
435 Sample configuration file prompting for field values:
436
437 [ req ]
438 default_bits = 1024
439 default_keyfile = privkey.pem
440 distinguished_name = req_distinguished_name
441 attributes = req_attributes
442 x509_extensions = v3_ca
443
444 dirstring_type = nobmp
445
446 [ req_distinguished_name ]
447 countryName = Country Name (2 letter code)
448 countryName_default = AU
449 countryName_min = 2
450 countryName_max = 2
451
452 localityName = Locality Name (eg, city)
453
454 organizationalUnitName = Organizational Unit Name (eg, section)
455
456 commonName = Common Name (eg, YOUR name)
457 commonName_max = 64
458
459 emailAddress = Email Address
460 emailAddress_max = 40
461
462 [ req_attributes ]
463 challengePassword = A challenge password
464 challengePassword_min = 4
465 challengePassword_max = 20
466
467 [ v3_ca ]
468
469 subjectKeyIdentifier=hash
470 authorityKeyIdentifier=keyid:always,issuer:always
471 basicConstraints = CA:true
472
473 Sample configuration containing all field values:
474
475 RANDFILE = $ENV::HOME/.rnd
476
477 [ req ]
478 default_bits = 1024
479 default_keyfile = keyfile.pem
480 distinguished_name = req_distinguished_name
481 attributes = req_attributes
482 prompt = no
483 output_password = mypass
484
485 [ req_distinguished_name ]
486 C = GB
487 ST = Test State or Province
488 L = Test Locality
489 O = Organization Name
490 OU = Organizational Unit Name
491 CN = Common Name
492 emailAddress = test@email.address
493
494 [ req_attributes ]
495 challengePassword = A challenge password
496
498 The header and footer lines in the PEM format are normally:
499
500 -----BEGIN CERTIFICATE REQUEST-----
501 -----END CERTIFICATE REQUEST-----
502
503 some software (some versions of Netscape certificate server) instead
504 needs:
505
506 -----BEGIN NEW CERTIFICATE REQUEST-----
507 -----END NEW CERTIFICATE REQUEST-----
508
509 which is produced with the -newhdr option but is otherwise compatible.
510 Either form is accepted transparently on input.
511
512 The certificate requests generated by Xenroll with MSIE have extensions
513 added. It includes the keyUsage extension which determines the type of
514 key (signature only or general purpose) and any additional OIDs entered
515 by the script in an extendedKeyUsage extension.
516
518 The following messages are frequently asked about:
519
520 Using configuration from /some/path/openssl.cnf
521 Unable to load config info
522
523 This is followed some time later by...
524
525 unable to find 'distinguished_name' in config
526 problems making Certificate Request
527
528 The first error message is the clue: it can't find the configuration
529 file! Certain operations (like examining a certificate request) don't
530 need a configuration file so its use isn't enforced. Generation of
531 certificates or requests however does need a configuration file. This
532 could be regarded as a bug.
533
534 Another puzzling message is this:
535
536 Attributes:
537 a0:00
538
539 this is displayed when no attributes are present and the request
540 includes the correct empty SET OF structure (the DER encoding of which
541 is 0xa0 0x00). If you just see:
542
543 Attributes:
544
545 then the SET OF is missing and the encoding is technically invalid (but
546 it is tolerated). See the description of the command line option
547 -asn1-kludge for more information.
548
550 The variable OPENSSL_CONF if defined allows an alternative
551 configuration file location to be specified, it will be overridden by
552 the -config command line switch if it is present. For compatibility
553 reasons the SSLEAY_CONF environment variable serves the same purpose
554 but its use is discouraged.
555
557 OpenSSL's handling of T61Strings (aka TeletexStrings) is broken: it
558 effectively treats them as ISO-8859-1 (Latin 1), Netscape and MSIE have
559 similar behaviour. This can cause problems if you need characters that
560 aren't available in PrintableStrings and you don't want to or can't use
561 BMPStrings.
562
563 As a consequence of the T61String handling the only correct way to
564 represent accented characters in OpenSSL is to use a BMPString:
565 unfortunately Netscape currently chokes on these. If you have to use
566 accented characters with Netscape and MSIE then you currently need to
567 use the invalid T61String form.
568
569 The current prompting is not very friendly. It doesn't allow you to
570 confirm what you've just entered. Other things like extensions in
571 certificate requests are statically defined in the configuration file.
572 Some of these: like an email address in subjectAltName should be input
573 by the user.
574
576 x509(1), ca(1), genrsa(1), gendsa(1), config(5), x509v3_config(5)
577
578
579
5801.0.1e 2017-03-22 REQ(1)