1REQ(1)                              OpenSSL                             REQ(1)
2
3
4

NAME

6       req - PKCS#10 certificate request and certificate generating utility.
7

SYNOPSIS

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]
14       [-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

DESCRIPTION

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

COMMAND OPTIONS

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, a large random number
177           will be used for the 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           outputted 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

CONFIGURATION FILE FORMAT

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           Specifies the default key size in bits.
270
271           This option is used in conjunction with the -new option to generate
272           a new key. It can be overridden by specifying an explicit key size
273           in the -newkey option. The smallest accepted key size is 512 bits.
274           If no key size is specified then 2048 bits is used.
275
276       default_keyfile
277           This is the default filename to write a private key to. If not
278           specified the key is written to standard output. This can be
279           overridden by the -keyout option.
280
281       oid_file
282           This specifies a file containing additional OBJECT IDENTIFIERS.
283           Each line of the file should consist of the numerical form of the
284           object identifier followed by white space then the short name
285           followed by white space and finally the long name.
286
287       oid_section
288           This specifies a section in the configuration file containing extra
289           object identifiers. Each line should consist of the short name of
290           the object identifier followed by = and the numerical form. The
291           short and long names are the same when this option is used.
292
293       RANDFILE
294           This specifies a filename in which random number seed information
295           is placed and read from, or an EGD socket (see RAND_egd(3)).  It is
296           used for private key generation.
297
298       encrypt_key
299           If this is set to no then if a private key is generated it is not
300           encrypted. This is equivalent to the -nodes command line option.
301           For compatibility encrypt_rsa_key is an equivalent option.
302
303       default_md
304           This option specifies the digest algorithm to use. Possible values
305           include md5 sha1 mdc2. If not present then MD5 is used. This option
306           can be overridden on the command line.
307
308       string_mask
309           This option masks out the use of certain string types in certain
310           fields. Most users will not need to change this option.
311
312           It can be set to several values default which is also the default
313           option uses PrintableStrings, T61Strings and BMPStrings if the pkix
314           value is used then only PrintableStrings and BMPStrings will be
315           used. This follows the PKIX recommendation in RFC2459. If the
316           utf8only option is used then only UTF8Strings will be used: this is
317           the PKIX recommendation in RFC2459 after 2003. Finally the nombstr
318           option just uses PrintableStrings and T61Strings: certain software
319           has problems with BMPStrings and UTF8Strings: in particular
320           Netscape.
321
322       req_extensions
323           this specifies the configuration file section containing a list of
324           extensions to add to the certificate request. It can be overridden
325           by the -reqexts command line switch. See the x509v3_config(5)
326           manual page for details of the extension section format.
327
328       x509_extensions
329           this specifies the configuration file section containing a list of
330           extensions to add to certificate generated when the -x509 switch is
331           used. It can be overridden by the -extensions command line switch.
332
333       prompt
334           if set to the value no this disables prompting of certificate
335           fields and just takes values from the config file directly. It also
336           changes the expected format of the distinguished_name and
337           attributes sections.
338
339       utf8
340           if set to the value yes then field values to be interpreted as UTF8
341           strings, by default they are interpreted as ASCII. This means that
342           the field values, whether prompted from a terminal or obtained from
343           a configuration file, must be valid UTF8 strings.
344
345       attributes
346           this specifies the section containing any request attributes: its
347           format is the same as distinguished_name. Typically these may
348           contain the challengePassword or unstructuredName types. They are
349           currently ignored by OpenSSL's request signing utilities but some
350           CAs might want them.
351
352       distinguished_name
353           This specifies the section containing the distinguished name fields
354           to prompt for when generating a certificate or certificate request.
355           The format is described in the next section.
356

DISTINGUISHED NAME AND ATTRIBUTE SECTION FORMAT

358       There are two separate formats for the distinguished name and attribute
359       sections. If the prompt option is set to no then these sections just
360       consist of field names and values: for example,
361
362        CN=My Name
363        OU=My Organization
364        emailAddress=someone@somewhere.org
365
366       This allows external programs (e.g. GUI based) to generate a template
367       file with all the field names and values and just pass it to req. An
368       example of this kind of configuration file is contained in the EXAMPLES
369       section.
370
371       Alternatively if the prompt option is absent or not set to no then the
372       file contains field prompting information. It consists of lines of the
373       form:
374
375        fieldName="prompt"
376        fieldName_default="default field value"
377        fieldName_min= 2
378        fieldName_max= 4
379
380       "fieldName" is the field name being used, for example commonName (or
381       CN).  The "prompt" string is used to ask the user to enter the relevant
382       details. If the user enters nothing then the default value is used if
383       no default value is present then the field is omitted. A field can
384       still be omitted if a default value is present if the user just enters
385       the '.' character.
386
387       The number of characters entered must be between the fieldName_min and
388       fieldName_max limits: there may be additional restrictions based on the
389       field being used (for example countryName can only ever be two
390       characters long and must fit in a PrintableString).
391
392       Some fields (such as organizationName) can be used more than once in a
393       DN. This presents a problem because configuration files will not
394       recognize the same name occurring twice. To avoid this problem if the
395       fieldName contains some characters followed by a full stop they will be
396       ignored. So for example a second organizationName can be input by
397       calling it "1.organizationName".
398
399       The actual permitted field names are any object identifier short or
400       long names. These are compiled into OpenSSL and include the usual
401       values such as commonName, countryName, localityName, organizationName,
402       organizationalUnitName, stateOrProvinceName. Additionally emailAddress
403       is include as well as name, surname, givenName initials and
404       dnQualifier.
405
406       Additional object identifiers can be defined with the oid_file or
407       oid_section options in the configuration file. Any additional fields
408       will be treated as though they were a DirectoryString.
409

EXAMPLES

411       Examine and verify certificate request:
412
413        openssl req -in req.pem -text -verify -noout
414
415       Create a private key and then generate a certificate request from it:
416
417        openssl genrsa -out key.pem 2048
418        openssl req -new -key key.pem -out req.pem
419
420       The same but just using req:
421
422        openssl req -newkey rsa:2048 -keyout key.pem -out req.pem
423
424       Generate a self signed root certificate:
425
426        openssl req -x509 -newkey rsa:2048 -keyout key.pem -out req.pem
427
428       Example of a file pointed to by the oid_file option:
429
430        1.2.3.4        shortName       A longer Name
431        1.2.3.6        otherName       Other longer Name
432
433       Example of a section pointed to by oid_section making use of variable
434       expansion:
435
436        testoid1=1.2.3.5
437        testoid2=${testoid1}.6
438
439       Sample configuration file prompting for field values:
440
441        [ req ]
442        default_bits           = 2048
443        default_keyfile        = privkey.pem
444        distinguished_name     = req_distinguished_name
445        attributes             = req_attributes
446        x509_extensions        = v3_ca
447
448        dirstring_type = nobmp
449
450        [ req_distinguished_name ]
451        countryName                    = Country Name (2 letter code)
452        countryName_default            = AU
453        countryName_min                = 2
454        countryName_max                = 2
455
456        localityName                   = Locality Name (eg, city)
457
458        organizationalUnitName         = Organizational Unit Name (eg, section)
459
460        commonName                     = Common Name (eg, YOUR name)
461        commonName_max                 = 64
462
463        emailAddress                   = Email Address
464        emailAddress_max               = 40
465
466        [ req_attributes ]
467        challengePassword              = A challenge password
468        challengePassword_min          = 4
469        challengePassword_max          = 20
470
471        [ v3_ca ]
472
473        subjectKeyIdentifier=hash
474        authorityKeyIdentifier=keyid:always,issuer:always
475        basicConstraints = CA:true
476
477       Sample configuration containing all field values:
478
479        RANDFILE               = $ENV::HOME/.rnd
480
481        [ req ]
482        default_bits           = 2048
483        default_keyfile        = keyfile.pem
484        distinguished_name     = req_distinguished_name
485        attributes             = req_attributes
486        prompt                 = no
487        output_password        = mypass
488
489        [ req_distinguished_name ]
490        C                      = GB
491        ST                     = Test State or Province
492        L                      = Test Locality
493        O                      = Organization Name
494        OU                     = Organizational Unit Name
495        CN                     = Common Name
496        emailAddress           = test@email.address
497
498        [ req_attributes ]
499        challengePassword              = A challenge password
500

NOTES

502       The header and footer lines in the PEM format are normally:
503
504        -----BEGIN CERTIFICATE REQUEST-----
505        -----END CERTIFICATE REQUEST-----
506
507       some software (some versions of Netscape certificate server) instead
508       needs:
509
510        -----BEGIN NEW CERTIFICATE REQUEST-----
511        -----END NEW CERTIFICATE REQUEST-----
512
513       which is produced with the -newhdr option but is otherwise compatible.
514       Either form is accepted transparently on input.
515
516       The certificate requests generated by Xenroll with MSIE have extensions
517       added. It includes the keyUsage extension which determines the type of
518       key (signature only or general purpose) and any additional OIDs entered
519       by the script in an extendedKeyUsage extension.
520

DIAGNOSTICS

522       The following messages are frequently asked about:
523
524               Using configuration from /some/path/openssl.cnf
525               Unable to load config info
526
527       This is followed some time later by...
528
529               unable to find 'distinguished_name' in config
530               problems making Certificate Request
531
532       The first error message is the clue: it can't find the configuration
533       file! Certain operations (like examining a certificate request) don't
534       need a configuration file so its use isn't enforced. Generation of
535       certificates or requests however does need a configuration file. This
536       could be regarded as a bug.
537
538       Another puzzling message is this:
539
540               Attributes:
541                   a0:00
542
543       this is displayed when no attributes are present and the request
544       includes the correct empty SET OF structure (the DER encoding of which
545       is 0xa0 0x00). If you just see:
546
547               Attributes:
548
549       then the SET OF is missing and the encoding is technically invalid (but
550       it is tolerated). See the description of the command line option
551       -asn1-kludge for more information.
552

ENVIRONMENT VARIABLES

554       The variable OPENSSL_CONF if defined allows an alternative
555       configuration file location to be specified, it will be overridden by
556       the -config command line switch if it is present. For compatibility
557       reasons the SSLEAY_CONF environment variable serves the same purpose
558       but its use is discouraged.
559

BUGS

561       OpenSSL's handling of T61Strings (aka TeletexStrings) is broken: it
562       effectively treats them as ISO-8859-1 (Latin 1), Netscape and MSIE have
563       similar behaviour.  This can cause problems if you need characters that
564       aren't available in PrintableStrings and you don't want to or can't use
565       BMPStrings.
566
567       As a consequence of the T61String handling the only correct way to
568       represent accented characters in OpenSSL is to use a BMPString:
569       unfortunately Netscape currently chokes on these. If you have to use
570       accented characters with Netscape and MSIE then you currently need to
571       use the invalid T61String form.
572
573       The current prompting is not very friendly. It doesn't allow you to
574       confirm what you've just entered. Other things like extensions in
575       certificate requests are statically defined in the configuration file.
576       Some of these: like an email address in subjectAltName should be input
577       by the user.
578

SEE ALSO

580       x509(1), ca(1), genrsa(1), gendsa(1), config(5), x509v3_config(5)
581
582
583
5841.0.2k                            2019-03-12                            REQ(1)
Impressum