=pod {- OpenSSL::safe::output_do_not_edit_headers(); -} =head1 NAME openssl-req - PKCS#10 certificate request and certificate generating command =head1 SYNOPSIS B B [B<-help>] [B<-inform> B|B] [B<-outform> B|B] [B<-in> I] [B<-passin> I] [B<-out> I] [B<-passout> I] [B<-text>] [B<-pubkey>] [B<-noout>] [B<-verify>] [B<-modulus>] [B<-new>] [B<-newkey> I] [B<-pkeyopt> I:I] [B<-noenc>] [B<-nodes>] [B<-key> I|I] [B<-keyform> B|B|B|B] [B<-keyout> I] [B<-keygen_engine> I] [B<-I>] [B<-config> I] [B<-section> I] [B<-x509>] [B<-CA> I|I] [B<-CAkey> I|I] [B<-days> I] [B<-set_serial> I] [B<-newhdr>] [B<-copy_extensions> I] [B<-addext> I] [B<-extensions> I
] [B<-reqexts> I
] [B<-precert>] [B<-utf8>] [B<-reqopt>] [B<-subject>] [B<-subj> I] [B<-multivalue-rdn>] [B<-sigopt> I:I] [B<-vfyopt> I:I] [B<-batch>] [B<-verbose>] {- $OpenSSL::safe::opt_name_synopsis -} {- $OpenSSL::safe::opt_r_synopsis -} {- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_provider_synopsis -} =head1 DESCRIPTION This command primarily creates and processes certificate requests (CSRs) in PKCS#10 format. It can additionally create self-signed certificates for use as root CAs for example. =head1 OPTIONS =over 4 =item B<-help> Print out a usage message. =item B<-inform> B|B, B<-outform> B|B The input and output formats; unspecified by default. See L for details. The data is a PKCS#10 object. =item B<-in> I This specifies the input filename to read a request from. This defaults to standard input unless B<-x509> or B<-CA> is specified. A request is only read if the creation options (B<-new> or B<-newkey> or B<-precert>) are not specified. =item B<-sigopt> I:I Pass options to the signature algorithm during sign operations. Names and values of these options are algorithm-specific. =item B<-vfyopt> I:I Pass options to the signature algorithm during verify operations. Names and values of these options are algorithm-specific. =begin comment Maybe it would be preferable to only have -opts instead of -sigopt and -vfyopt? They are both present here to be compatible with L, which supports both options for good reasons. =end comment =item B<-passin> I The password source for private key and certificate input. For more information about the format of B see L. =item B<-passout> I The password source for the output file. For more information about the format of B see L. =item B<-out> I This specifies the output filename to write to or standard output by default. =item B<-text> Prints out the certificate request in text form. =item B<-subject> Prints out the certificate request subject (or certificate subject if B<-x509> is in use). =item B<-pubkey> Prints out the public key. =item B<-noout> This option prevents output of the encoded version of the certificate request. =item B<-modulus> Prints out the value of the modulus of the public key contained in the request. =item B<-verify> Verifies the self-signature on the request. =item B<-new> This option generates a new certificate request. It will prompt the user for the relevant field values. The actual fields prompted for and their maximum and minimum sizes are specified in the configuration file and any requested extensions. If the B<-key> option is not given it will generate a new private key using information specified in the configuration file or given with the B<-newkey> and B<-pkeyopt> options, else by default an RSA key with 2048 bits length. =item B<-newkey> I This option is used to generate a new private key unless B<-key> is given. It is subsequently used as if it was given using the B<-key> option. This option implies the B<-new> flag to create a new certificate request or a new certificate in case B<-x509> is given. The argument takes one of several forms. [B]I generates an RSA key I in size. If I is omitted, i.e., B<-newkey> B is specified, the default key size specified in the configuration file with the B option is used if present, else 2048. All other algorithms support the B<-newkey> I:I form, where I is an algorithm parameter file, created with C or an X.509 certificate for a key with appropriate algorithm. BI generates a key using the parameter file or certificate I, the algorithm is determined by the parameters. I[:I] generates a key using the given algorithm I. If a parameter file I is given then the parameters specified there are used, where the algorithm parameters must match I. If algorithm parameters are not given, any necessary parameters should be specified via the B<-pkeyopt> option. BI generates a DSA key using the parameters in the file I. BI generates EC key (usable both with ECDSA or ECDH algorithms), BI generates GOST R 34.10-2001 key (requires B engine configured in the configuration file). If just B is specified a parameter set should be specified by B<-pkeyopt> I =item B<-pkeyopt> I:I Set the public key algorithm option I to I. The precise set of options supported depends on the public key algorithm used and its implementation. See L for more details. =item B<-key> I|I This option provides the private key for signing a new certificate or certificate request. Unless B<-in> is given, the corresponding public key is placed in the new certificate or certificate request, resulting in a self-signature. For certificate signing this option is overridden by the B<-CA> option. This option also accepts PKCS#8 format private keys for PEM format files. =item B<-keyform> B|B|B|B The format of the private key; unspecified by default. See L for details. =item B<-keyout> I This gives the filename to write any private key to that has been newly created or read from B<-key>. If neither the B<-keyout> option nor the B<-key> option are given then the filename specified in the configuration file with the B option is used, if present. Thus, if you want to write the private key and the B<-key> option is provided, you should provide the B<-keyout> option explicitly. If a new key is generated and no filename is specified the key is written to standard output. =item B<-noenc> If this option is specified then if a private key is created it will not be encrypted. =item B<-nodes> This option is deprecated since OpenSSL 3.0; use B<-noenc> instead. =item B<-I> This specifies the message digest to sign the request. Any digest supported by the OpenSSL B command can be used. This overrides the digest algorithm specified in the configuration file. Some public key algorithms may override this choice. For instance, DSA signatures always use SHA1, GOST R 34.10 signatures always use GOST R 34.11-94 (B<-md_gost94>), Ed25519 and Ed448 never use any digest. =item B<-config> I This allows an alternative configuration file to be specified. Optional; for a description of the default value, see L. =item B<-section> I Specifies the name of the section to use; the default is B. =item B<-subj> I Sets subject name for new request or supersedes the subject name when processing a certificate request. The arg must be formatted as C. Special characters may be escaped by C<\> (backslash), whitespace is retained. Empty values are permitted, but the corresponding type will not be included in the request. Giving a single C will lead to an empty sequence of RDNs (a NULL-DN). Multi-valued RDNs can be formed by placing a C<+> character instead of a C between the AttributeValueAssertions (AVAs) that specify the members of the set. Example: C =item B<-multivalue-rdn> This option has been deprecated and has no effect. =item B<-x509> This option outputs a certificate instead of a certificate request. This is typically used to generate test certificates. It is implied by the B<-CA> option. This option implies the B<-new> flag if B<-in> is not given. If an existing request is specified with the B<-in> option, it is converted to the a certificate; otherwise a request is created from scratch. Unless specified using the B<-set_serial> option, a large random number will be used for the serial number. Unless the B<-copy_extensions> option is used, X.509 extensions are not copied from any provided request input file. X.509 extensions to be added can be specified in the configuration file or using the B<-addext> option. =item B<-CA> I|I Specifies the "CA" certificate to be used for signing a new certificate and implies use of B<-x509>. When present, this behaves like a "micro CA" as follows: The subject name of the "CA" certificate is placed as issuer name in the new certificate, which is then signed using the "CA" key given as specified below. =item B<-CAkey> I|I Sets the "CA" private key to sign a certificate with. The private key must match the public key of the certificate given with B<-CA>. If this option is not provided then the key must be present in the B<-CA> input. =item B<-days> I When B<-x509> is in use this specifies the number of days to certify the certificate for, otherwise it is ignored. I should be a positive integer. The default is 30 days. =item B<-set_serial> I Serial number to use when outputting a self-signed certificate. This may be specified as a decimal value or a hex value if preceded by C<0x>. If not given, a large random number will be used. =item B<-copy_extensions> I Determines how X.509 extensions in certificate requests should be handled when B<-x509> is in use. If I is B or this option is not present then extensions are ignored. If I is B or B then all extensions in the request are copied to the certificate. The main use of this option is to allow a certificate request to supply values for certain extensions such as subjectAltName. =item B<-addext> I Add a specific extension to the certificate (if B<-x509> is in use) or certificate request. The argument must have the form of a key=value pair as it would appear in a config file. This option can be given multiple times. =item B<-extensions> I
=item B<-reqexts> I
These options specify alternative sections to include certificate extensions (if B<-x509> is in use) or certificate request extensions. This allows several different sections to be used in the same configuration file to specify requests for a variety of purposes. =item B<-precert> A poison extension will be added to the certificate, making it a "pre-certificate" (see RFC6962). This can be submitted to Certificate Transparency logs in order to obtain signed certificate timestamps (SCTs). These SCTs can then be embedded into the pre-certificate as an extension, before removing the poison and signing the certificate. This implies the B<-new> flag. =item B<-utf8> This option causes field values to be interpreted as UTF8 strings, by default they are interpreted as ASCII. This means that the field values, whether prompted from a terminal or obtained from a configuration file, must be valid UTF8 strings. =item B<-reqopt> I