{
    "mode": "man",
    "parameter": "openssl-req",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/openssl-req/1/json",
    "generated": "2026-07-05T02:09:58Z",
    "synopsis": "openssl req [-help] [-inform DER|PEM] [-outform DER|PEM] [-in filename] [-passin arg] [-out\nfilename] [-passout arg] [-text] [-pubkey] [-noout] [-verify] [-modulus] [-new] [-newkey arg]\n[-pkeyopt opt:value] [-noenc] [-nodes] [-key filename|uri] [-keyform DER|PEM|P12|ENGINE]\n[-keyout filename] [-keygenengine id] [-ddiiggeesstt] [-config filename] [-section name] [-x509]\n[-CA filename|uri] [-CAkey filename|uri] [-days n] [-setserial n] [-newhdr]\n[-copyextensions arg] [-addext ext] [-extensions section] [-reqexts section] [-precert]\n[-utf8] [-reqopt] [-subject] [-subj arg] [-multivalue-rdn] [-sigopt nm:v] [-vfyopt nm:v]\n[-batch] [-verbose] [-nameopt option] [-rand files] [-writerand file] [-engine id] [-provider\nname] [-provider-path path] [-propquery propq]",
    "sections": {
        "NAME": {
            "content": "openssl-req - PKCS#10 certificate request and certificate generating command\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "openssl req [-help] [-inform DER|PEM] [-outform DER|PEM] [-in filename] [-passin arg] [-out\nfilename] [-passout arg] [-text] [-pubkey] [-noout] [-verify] [-modulus] [-new] [-newkey arg]\n[-pkeyopt opt:value] [-noenc] [-nodes] [-key filename|uri] [-keyform DER|PEM|P12|ENGINE]\n[-keyout filename] [-keygenengine id] [-ddiiggeesstt] [-config filename] [-section name] [-x509]\n[-CA filename|uri] [-CAkey filename|uri] [-days n] [-setserial n] [-newhdr]\n[-copyextensions arg] [-addext ext] [-extensions section] [-reqexts section] [-precert]\n[-utf8] [-reqopt] [-subject] [-subj arg] [-multivalue-rdn] [-sigopt nm:v] [-vfyopt nm:v]\n[-batch] [-verbose] [-nameopt option] [-rand files] [-writerand file] [-engine id] [-provider\nname] [-provider-path path] [-propquery propq]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This command primarily creates and processes certificate requests (CSRs) in PKCS#10 format.\nIt can additionally create self-signed certificates for use as root CAs for example.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-help",
                    "content": "Print out a usage message.\n"
                },
                {
                    "name": "-inform -outform",
                    "content": "The input and output formats; unspecified by default.  See openssl-format-options(1) for\ndetails.\n\nThe data is a PKCS#10 object.\n"
                },
                {
                    "name": "-in",
                    "content": "This specifies the input filename to read a request from.  This defaults to standard\ninput unless -x509 or -CA is specified.  A request is only read if the creation options\n(-new or -newkey or -precert) are not specified.\n"
                },
                {
                    "name": "-sigopt",
                    "content": "Pass options to the signature algorithm during sign operations.  Names and values of\nthese options are algorithm-specific.\n"
                },
                {
                    "name": "-vfyopt",
                    "content": "Pass options to the signature algorithm during verify operations.  Names and values of\nthese options are algorithm-specific.\n"
                },
                {
                    "name": "-passin",
                    "content": "The password source for private key and certificate input.  For more information about\nthe format of arg see openssl-passphrase-options(1).\n"
                },
                {
                    "name": "-passout",
                    "content": "The password source for the output file.  For more information about the format of arg\nsee openssl-passphrase-options(1).\n"
                },
                {
                    "name": "-out",
                    "content": "This specifies the output filename to write to or standard output by default.\n"
                },
                {
                    "name": "-text",
                    "content": "Prints out the certificate request in text form.\n"
                },
                {
                    "name": "-subject",
                    "content": "Prints out the certificate request subject (or certificate subject if -x509 is in use).\n"
                },
                {
                    "name": "-pubkey",
                    "content": "Prints out the public key.\n"
                },
                {
                    "name": "-noout",
                    "content": "This option prevents output of the encoded version of the certificate request.\n"
                },
                {
                    "name": "-modulus",
                    "content": "Prints out the value of the modulus of the public key contained in the request.\n"
                },
                {
                    "name": "-verify",
                    "content": "Verifies the self-signature on the request.\n"
                },
                {
                    "name": "-new",
                    "content": "This option generates a new certificate request. It will prompt the user for the relevant\nfield values. The actual fields prompted for and their maximum and minimum sizes are\nspecified in the configuration file and any requested extensions.\n\nIf the -key option is not given it will generate a new private key using information\nspecified in the configuration file or given with the -newkey and -pkeyopt options, else\nby default an RSA key with 2048 bits length.\n"
                },
                {
                    "name": "-newkey",
                    "content": "This option is used to generate a new private key unless -key is given.  It is\nsubsequently used as if it was given using the -key option.\n\nThis option implies the -new flag to create a new certificate request or a new\ncertificate in case -x509 is given.\n\nThe argument takes one of several forms.\n\n[rsa:]nbits generates an RSA key nbits in size.  If nbits is omitted, i.e., -newkey rsa\nis specified, the default key size specified in the configuration file with the\ndefaultbits option is used if present, else 2048.\n\nAll other algorithms support the -newkey algname:file form, where file is an algorithm\nparameter file, created with \"openssl genpkey -genparam\" or an X.509 certificate for a\nkey with appropriate algorithm.\n\nparam:file generates a key using the parameter file or certificate file, the algorithm is\ndetermined by the parameters.\n\nalgname[:file] generates a key using the given algorithm algname.  If a parameter file\nfile is given then the parameters specified there are used, where the algorithm\nparameters must match algname.  If algorithm parameters are not given, any necessary\nparameters should be specified via the -pkeyopt option.\n\ndsa:filename generates a DSA key using the parameters in the file filename. ec:filename\ngenerates EC key (usable both with ECDSA or ECDH algorithms), gost2001:filename generates\nGOST R 34.10-2001 key (requires gost engine configured in the configuration file). If\njust gost2001 is specified a parameter set should be specified by -pkeyopt paramset:X\n"
                },
                {
                    "name": "-pkeyopt",
                    "content": "Set the public key algorithm option opt to value. The precise set of options supported\ndepends on the public key algorithm used and its implementation.  See \"KEY GENERATION\nOPTIONS\" in openssl-genpkey(1) for more details.\n"
                },
                {
                    "name": "-key",
                    "content": "This option provides the private key for signing a new certificate or certificate\nrequest.  Unless -in is given, the corresponding public key is placed in the new\ncertificate or certificate request, resulting in a self-signature.\n\nFor certificate signing this option is overridden by the -CA option.\n\nThis option also accepts PKCS#8 format private keys for PEM format files.\n"
                },
                {
                    "name": "-keyform",
                    "content": "The format of the private key; unspecified by default.  See openssl-format-options(1) for\ndetails.\n"
                },
                {
                    "name": "-keyout",
                    "content": "This gives the filename to write any private key to that has been newly created or read\nfrom -key.  If neither the -keyout option nor the -key option are given then the filename\nspecified in the configuration file with the defaultkeyfile option is used, if present.\nThus, if you want to write the private key and the -key option is provided, you should\nprovide the -keyout option explicitly.  If a new key is generated and no filename is\nspecified the key is written to standard output.\n"
                },
                {
                    "name": "-noenc",
                    "content": "If this option is specified then if a private key is created it will not be encrypted.\n"
                },
                {
                    "name": "-nodes",
                    "content": "This option is deprecated since OpenSSL 3.0; use -noenc instead.\n\n-ddiiggeesstt\nThis specifies the message digest to sign the request.  Any digest supported by the\nOpenSSL dgst command can be used.  This overrides the digest algorithm specified in the\nconfiguration file.\n\nSome public key algorithms may override this choice. For instance, DSA signatures always\nuse SHA1, GOST R 34.10 signatures always use GOST R 34.11-94 (-mdgost94), Ed25519 and\nEd448 never use any digest.\n"
                },
                {
                    "name": "-config",
                    "content": "This allows an alternative configuration file to be specified.  Optional; for a\ndescription of the default value, see \"COMMAND SUMMARY\" in openssl(1).\n"
                },
                {
                    "name": "-section",
                    "content": "Specifies the name of the section to use; the default is req.\n"
                },
                {
                    "name": "-subj",
                    "content": "Sets subject name for new request or supersedes the subject name when processing a\ncertificate request.\n\nThe arg must be formatted as \"/type0=value0/type1=value1/type2=...\".  Special characters\nmay be escaped by \"\\\" (backslash), whitespace is retained.  Empty values are permitted,\nbut the corresponding type will not be included in the request.  Giving a single \"/\" will\nlead to an empty sequence of RDNs (a NULL-DN).  Multi-valued RDNs can be formed by\nplacing a \"+\" character instead of a \"/\" between the AttributeValueAssertions (AVAs) that\nspecify the members of the set.  Example:\n\n\"/DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe\"\n"
                },
                {
                    "name": "-multivalue-rdn",
                    "content": "This option has been deprecated and has no effect.\n"
                },
                {
                    "name": "-x509",
                    "content": "This option outputs a certificate instead of a certificate request.  This is typically\nused to generate test certificates.  It is implied by the -CA option.\n\nThis option implies the -new flag if -in is not given.\n\nIf an existing request is specified with the -in option, it is converted to the a\ncertificate; otherwise a request is created from scratch.\n\nUnless specified using the -setserial option, a large random number will be used for the\nserial number.\n\nUnless the -copyextensions option is used, X.509 extensions are not copied from any\nprovided request input file.\n\nX.509 extensions to be added can be specified in the configuration file or using the\n-addext option.\n"
                },
                {
                    "name": "-CA",
                    "content": "Specifies the \"CA\" certificate to be used for signing a new certificate and implies use\nof -x509.  When present, this behaves like a \"micro CA\" as follows: The subject name of\nthe \"CA\" certificate is placed as issuer name in the new certificate, which is then\nsigned using the \"CA\" key given as specified below.\n"
                },
                {
                    "name": "-CAkey",
                    "content": "Sets the \"CA\" private key to sign a certificate with.  The private key must match the\npublic key of the certificate given with -CA.  If this option is not provided then the\nkey must be present in the -CA input.\n"
                },
                {
                    "name": "-days",
                    "content": "When -x509 is in use this specifies the number of days to certify the certificate for,\notherwise it is ignored. n should be a positive integer. The default is 30 days.\n"
                },
                {
                    "name": "-set",
                    "content": "Serial number to use when outputting a self-signed certificate.  This may be specified as\na decimal value or a hex value if preceded by \"0x\".  If not given, a large random number\nwill be used.\n"
                },
                {
                    "name": "-copy",
                    "content": "Determines how X.509 extensions in certificate requests should be handled when -x509 is\nin use.  If arg is none or this option is not present then extensions are ignored.  If\narg is copy or copyall then all extensions in the request are copied to the certificate.\n\nThe main use of this option is to allow a certificate request to supply values for\ncertain extensions such as subjectAltName.\n"
                },
                {
                    "name": "-addext",
                    "content": "Add a specific extension to the certificate (if -x509 is in use) or certificate request.\nThe argument must have the form of a key=value pair as it would appear in a config file.\n\nThis option can be given multiple times.\n"
                },
                {
                    "name": "-extensions",
                    "content": ""
                },
                {
                    "name": "-reqexts",
                    "content": "These options specify alternative sections to include certificate extensions (if -x509 is\nin use) or certificate request extensions.  This allows several different sections to be\nused in the same configuration file to specify requests for a variety of purposes.\n"
                },
                {
                    "name": "-precert",
                    "content": "A poison extension will be added to the certificate, making it a \"pre-certificate\" (see\nRFC6962). This can be submitted to Certificate Transparency logs in order to obtain\nsigned certificate timestamps (SCTs).  These SCTs can then be embedded into the pre-\ncertificate as an extension, before removing the poison and signing the certificate.\n\nThis implies the -new flag.\n"
                },
                {
                    "name": "-utf8",
                    "content": "This option causes field values to be interpreted as UTF8 strings, by default they are\ninterpreted as ASCII. This means that the field values, whether prompted from a terminal\nor obtained from a configuration file, must be valid UTF8 strings.\n"
                },
                {
                    "name": "-reqopt",
                    "content": "Customise the printing format used with -text. The option argument can be a single option\nor multiple options separated by commas.\n\nSee discussion of the  -certopt parameter in the openssl-x509(1) command.\n"
                },
                {
                    "name": "-newhdr",
                    "content": "Adds the word NEW to the PEM file header and footer lines on the outputted request. Some\nsoftware (Netscape certificate server) and some CAs need this.\n"
                },
                {
                    "name": "-batch",
                    "content": "Non-interactive mode.\n"
                },
                {
                    "name": "-verbose",
                    "content": "Print extra details about the operations being performed.\n"
                },
                {
                    "name": "-keygen",
                    "content": "Specifies an engine (by its unique id string) which would be used for key generation\noperations.\n"
                },
                {
                    "name": "-nameopt",
                    "content": "This specifies how the subject or issuer names are displayed.  See\nopenssl-namedisplay-options(1) for details.\n"
                },
                {
                    "name": "-rand -writerand",
                    "content": "See \"Random State Options\" in openssl(1) for details.\n"
                },
                {
                    "name": "-engine",
                    "content": "See \"Engine Options\" in openssl(1).  This option is deprecated.\n"
                },
                {
                    "name": "-provider",
                    "content": ""
                },
                {
                    "name": "-provider-path",
                    "content": ""
                },
                {
                    "name": "-propquery",
                    "content": "See \"Provider Options\" in openssl(1), provider(7), and property(7).\n"
                }
            ]
        },
        "CONFIGURATION FILE FORMAT": {
            "content": "The configuration options are specified in the req section of the configuration file. An\nalternate name be specified by using the -section option.  As with all configuration files,\nif no value is specified in the specific section then the initial unnamed or default section\nis searched too.\n\nThe options available are described in detail below.\n\ninputpassword, outputpassword\nThe passwords for the input private key file (if present) and the output private key file\n(if one will be created). The command line options passin and passout override the\nconfiguration file values.\n\ndefaultbits\nSpecifies the default key size in bits.\n\nThis option is used in conjunction with the -new option to generate a new key. It can be\noverridden by specifying an explicit key size in the -newkey option. The smallest\naccepted key size is 512 bits. If no key size is specified then 2048 bits is used.\n\ndefaultkeyfile\nThis is the default filename to write a private key to. If not specified the key is\nwritten to standard output. This can be overridden by the -keyout option.\n\noidfile\nThis specifies a file containing additional OBJECT IDENTIFIERS.  Each line of the file\nshould consist of the numerical form of the object identifier followed by whitespace then\nthe short name followed by whitespace and finally the long name.\n\noidsection\nThis specifies a section in the configuration file containing extra object identifiers.\nEach line should consist of the short name of the object identifier followed by = and the\nnumerical form. The short and long names are the same when this option is used.\n\nRANDFILE\nAt startup the specified file is loaded into the random number generator, and at exit 256\nbytes will be written to it.  It is used for private key generation.\n\nencryptkey\nIf this is set to no then if a private key is generated it is not encrypted. This is\nequivalent to the -noenc command line option. For compatibility encryptrsakey is an\nequivalent option.\n\ndefaultmd\nThis option specifies the digest algorithm to use. Any digest supported by the OpenSSL\ndgst command can be used. This option can be overridden on the command line. Certain\nsigning algorithms (i.e. Ed25519 and Ed448) will ignore any digest that has been set.\n\nstringmask\nThis option masks out the use of certain string types in certain fields. Most users will\nnot need to change this option.\n\nIt can be set to several values default which is also the default option uses\nPrintableStrings, T61Strings and BMPStrings if the pkix value is used then only\nPrintableStrings and BMPStrings will be used. This follows the PKIX recommendation in\nRFC2459. If the utf8only option is used then only UTF8Strings will be used: this is the\nPKIX recommendation in RFC2459 after 2003. Finally the nombstr option just uses\nPrintableStrings and T61Strings: certain software has problems with BMPStrings and\nUTF8Strings: in particular Netscape.\n\nreqextensions\nThis specifies the configuration file section containing a list of extensions to add to\nthe certificate request. It can be overridden by the -reqexts command line switch. See\nthe x509v3config(5) manual page for details of the extension section format.\n\nx509extensions\nThis specifies the configuration file section containing a list of extensions to add to\ncertificate generated when -x509 is in use.  It can be overridden by the -extensions\ncommand line switch.\n",
            "subsections": [
                {
                    "name": "prompt",
                    "content": "If set to the value no this disables prompting of certificate fields and just takes\nvalues from the config file directly. It also changes the expected format of the\ndistinguishedname and attributes sections.\n"
                },
                {
                    "name": "utf8",
                    "content": "If set to the value yes then field values to be interpreted as UTF8 strings, by default\nthey are interpreted as ASCII. This means that the field values, whether prompted from a\nterminal or obtained from a configuration file, must be valid UTF8 strings.\n"
                },
                {
                    "name": "attributes",
                    "content": "This specifies the section containing any request attributes: its format is the same as\ndistinguishedname. Typically these may contain the challengePassword or unstructuredName\ntypes. They are currently ignored by OpenSSL's request signing utilities but some CAs\nmight want them.\n\ndistinguishedname\nThis specifies the section containing the distinguished name fields to prompt for when\ngenerating a certificate or certificate request. The format is described in the next\nsection.\n"
                }
            ]
        },
        "DISTINGUISHED NAME AND ATTRIBUTE SECTION FORMAT": {
            "content": "There are two separate formats for the distinguished name and attribute sections. If the\nprompt option is set to no then these sections just consist of field names and values: for\nexample,\n\nCN=My Name\nOU=My Organization\nemailAddress=someone@somewhere.org\n\nThis allows external programs (e.g. GUI based) to generate a template file with all the field\nnames and values and just pass it to this command. An example of this kind of configuration\nfile is contained in the EXAMPLES section.\n\nAlternatively if the prompt option is absent or not set to no then the file contains field\nprompting information. It consists of lines of the form:\n\nfieldName=\"prompt\"\nfieldNamedefault=\"default field value\"\nfieldNamemin= 2\nfieldNamemax= 4\n\n\"fieldName\" is the field name being used, for example commonName (or CN).  The \"prompt\"\nstring is used to ask the user to enter the relevant details. If the user enters nothing then\nthe default value is used if no default value is present then the field is omitted. A field\ncan still be omitted if a default value is present if the user just enters the '.' character.\n\nThe number of characters entered must be between the fieldNamemin and fieldNamemax limits:\nthere may be additional restrictions based on the field being used (for example countryName\ncan only ever be two characters long and must fit in a PrintableString).\n\nSome fields (such as organizationName) can be used more than once in a DN. This presents a\nproblem because configuration files will not recognize the same name occurring twice. To\navoid this problem if the fieldName contains some characters followed by a full stop they\nwill be ignored. So for example a second organizationName can be input by calling it\n\"1.organizationName\".\n\nThe actual permitted field names are any object identifier short or long names. These are\ncompiled into OpenSSL and include the usual values such as commonName, countryName,\nlocalityName, organizationName, organizationalUnitName, stateOrProvinceName. Additionally\nemailAddress is included as well as name, surname, givenName, initials, and dnQualifier.\n\nAdditional object identifiers can be defined with the oidfile or oidsection options in the\nconfiguration file. Any additional fields will be treated as though they were a\nDirectoryString.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "Examine and verify certificate request:\n\nopenssl req -in req.pem -text -verify -noout\n\nCreate a private key and then generate a certificate request from it:\n\nopenssl genrsa -out key.pem 2048\nopenssl req -new -key key.pem -out req.pem\n\nThe same but just using req:\n\nopenssl req -newkey rsa:2048 -keyout key.pem -out req.pem\n\nGenerate a self-signed root certificate:\n\nopenssl req -x509 -newkey rsa:2048 -keyout key.pem -out req.pem\n\nCreate an SM2 private key and then generate a certificate request from it:\n\nopenssl ecparam -genkey -name SM2 -out sm2.key\nopenssl req -new -key sm2.key -out sm2.csr -sm3 -sigopt \"distid:1234567812345678\"\n\nExamine and verify an SM2 certificate request:\n\nopenssl req -verify -in sm2.csr -sm3 -vfyopt \"distid:1234567812345678\"\n\nExample of a file pointed to by the oidfile option:\n\n1.2.3.4        shortName       A longer Name\n1.2.3.6        otherName       Other longer Name\n\nExample of a section pointed to by oidsection making use of variable expansion:\n\ntestoid1=1.2.3.5\ntestoid2=${testoid1}.6\n\nSample configuration file prompting for field values:\n\n[ req ]\ndefaultbits           = 2048\ndefaultkeyfile        = privkey.pem\ndistinguishedname     = reqdistinguishedname\nattributes             = reqattributes\nreqextensions         = v3ca\n\ndirstringtype = nobmp\n\n[ reqdistinguishedname ]\ncountryName                    = Country Name (2 letter code)\ncountryNamedefault            = AU\ncountryNamemin                = 2\ncountryNamemax                = 2\n\nlocalityName                   = Locality Name (eg, city)\n\norganizationalUnitName         = Organizational Unit Name (eg, section)\n\ncommonName                     = Common Name (eg, YOUR name)\ncommonNamemax                 = 64\n\nemailAddress                   = Email Address\nemailAddressmax               = 40\n\n[ reqattributes ]\nchallengePassword              = A challenge password\nchallengePasswordmin          = 4\nchallengePasswordmax          = 20\n\n[ v3ca ]\n\nsubjectKeyIdentifier=hash\nauthorityKeyIdentifier=keyid:always,issuer:always\nbasicConstraints = critical, CA:true\n\nSample configuration containing all field values:\n\n[ req ]\ndefaultbits           = 2048\ndefaultkeyfile        = keyfile.pem\ndistinguishedname     = reqdistinguishedname\nattributes             = reqattributes\nprompt                 = no\noutputpassword        = mypass\n\n[ reqdistinguishedname ]\nC                      = GB\nST                     = Test State or Province\nL                      = Test Locality\nO                      = Organization Name\nOU                     = Organizational Unit Name\nCN                     = Common Name\nemailAddress           = test@email.address\n\n[ reqattributes ]\nchallengePassword              = A challenge password\n\nExample of giving the most common attributes (subject and extensions) on the command line:\n\nopenssl req -new -subj \"/C=GB/CN=foo\" \\\n-addext \"subjectAltName = DNS:foo.co.uk\" \\\n-addext \"certificatePolicies = 1.2.3.4\" \\\n-newkey rsa:2048 -keyout key.pem -out req.pem\n",
            "subsections": []
        },
        "NOTES": {
            "content": "The certificate requests generated by Xenroll with MSIE have extensions added. It includes\nthe keyUsage extension which determines the type of key (signature only or general purpose)\nand any additional OIDs entered by the script in an extendedKeyUsage extension.\n",
            "subsections": []
        },
        "DIAGNOSTICS": {
            "content": "The following messages are frequently asked about:\n\nUsing configuration from /some/path/openssl.cnf\nUnable to load config info\n\nThis is followed some time later by:\n\nunable to find 'distinguishedname' in config\nproblems making Certificate Request\n\nThe first error message is the clue: it can't find the configuration file! Certain operations\n(like examining a certificate request) don't need a configuration file so its use isn't\nenforced. Generation of certificates or requests however does need a configuration file. This\ncould be regarded as a bug.\n\nAnother puzzling message is this:\n\nAttributes:\na0:00\n\nthis is displayed when no attributes are present and the request includes the correct empty\nSET OF structure (the DER encoding of which is 0xa0 0x00). If you just see:\n\nAttributes:\n\nthen the SET OF is missing and the encoding is technically invalid (but it is tolerated). See\nthe description of the command line option -asn1-kludge for more information.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "OpenSSL's handling of T61Strings (aka TeletexStrings) is broken: it effectively treats them\nas ISO-8859-1 (Latin 1), Netscape and MSIE have similar behaviour.  This can cause problems\nif you need characters that aren't available in PrintableStrings and you don't want to or\ncan't use BMPStrings.\n\nAs a consequence of the T61String handling the only correct way to represent accented\ncharacters in OpenSSL is to use a BMPString: unfortunately Netscape currently chokes on\nthese. If you have to use accented characters with Netscape and MSIE then you currently need\nto use the invalid T61String form.\n\nThe current prompting is not very friendly. It doesn't allow you to confirm what you've just\nentered. Other things like extensions in certificate requests are statically defined in the\nconfiguration file. Some of these: like an email address in subjectAltName should be input by\nthe user.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "openssl(1), openssl-x509(1), openssl-ca(1), openssl-genrsa(1), openssl-gendsa(1), config(5),\nx509v3config(5)\n",
            "subsections": []
        },
        "HISTORY": {
            "content": "The -section option was added in OpenSSL 3.0.0.\n\nThe -multivalue-rdn option has become obsolete in OpenSSL 3.0.0 and has no effect.\n\nThe -engine option was deprecated in OpenSSL 3.0.  The <-nodes> option was deprecated in\nOpenSSL 3.0, too; use -noenc instead.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.\n\nLicensed under the Apache License 2.0 (the \"License\").  You may not use this file except in\ncompliance with the License.  You can obtain a copy in the file LICENSE in the source\ndistribution or at <https://www.openssl.org/source/license.html>.\n\n\n\n3.0.2                                        2026-06-02                            OPENSSL-REQ(1SSL)",
            "subsections": []
        }
    },
    "summary": "openssl-req - PKCS#10 certificate request and certificate generating command",
    "flags": [
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Print out a usage message."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "The input and output formats; unspecified by default. See openssl-format-options(1) for details. The data is a PKCS#10 object."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This specifies the input filename to read a request from. This defaults to standard input unless -x509 or -CA is specified. A request is only read if the creation options (-new or -newkey or -precert) are not specified."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Pass options to the signature algorithm during sign operations. Names and values of these options are algorithm-specific."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Pass options to the signature algorithm during verify operations. Names and values of these options are algorithm-specific."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "The password source for private key and certificate input. For more information about the format of arg see openssl-passphrase-options(1)."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "The password source for the output file. For more information about the format of arg see openssl-passphrase-options(1)."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This specifies the output filename to write to or standard output by default."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Prints out the certificate request in text form."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Prints out the certificate request subject (or certificate subject if -x509 is in use)."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Prints out the public key."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This option prevents output of the encoded version of the certificate request."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Prints out the value of the modulus of the public key contained in the request."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Verifies the self-signature on the request."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "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 -key option is not given it will generate a new private key using information specified in the configuration file or given with the -newkey and -pkeyopt options, else by default an RSA key with 2048 bits length."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This option is used to generate a new private key unless -key is given. It is subsequently used as if it was given using the -key option. This option implies the -new flag to create a new certificate request or a new certificate in case -x509 is given. The argument takes one of several forms. [rsa:]nbits generates an RSA key nbits in size. If nbits is omitted, i.e., -newkey rsa is specified, the default key size specified in the configuration file with the defaultbits option is used if present, else 2048. All other algorithms support the -newkey algname:file form, where file is an algorithm parameter file, created with \"openssl genpkey -genparam\" or an X.509 certificate for a key with appropriate algorithm. param:file generates a key using the parameter file or certificate file, the algorithm is determined by the parameters. algname[:file] generates a key using the given algorithm algname. If a parameter file file is given then the parameters specified there are used, where the algorithm parameters must match algname. If algorithm parameters are not given, any necessary parameters should be specified via the -pkeyopt option. dsa:filename generates a DSA key using the parameters in the file filename. ec:filename generates EC key (usable both with ECDSA or ECDH algorithms), gost2001:filename generates GOST R 34.10-2001 key (requires gost engine configured in the configuration file). If just gost2001 is specified a parameter set should be specified by -pkeyopt paramset:X"
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Set the public key algorithm option opt to value. The precise set of options supported depends on the public key algorithm used and its implementation. See \"KEY GENERATION OPTIONS\" in openssl-genpkey(1) for more details."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This option provides the private key for signing a new certificate or certificate request. Unless -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 -CA option. This option also accepts PKCS#8 format private keys for PEM format files."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "The format of the private key; unspecified by default. See openssl-format-options(1) for details."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This gives the filename to write any private key to that has been newly created or read from -key. If neither the -keyout option nor the -key option are given then the filename specified in the configuration file with the defaultkeyfile option is used, if present. Thus, if you want to write the private key and the -key option is provided, you should provide the -keyout option explicitly. If a new key is generated and no filename is specified the key is written to standard output."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "If this option is specified then if a private key is created it will not be encrypted."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This option is deprecated since OpenSSL 3.0; use -noenc instead. -ddiiggeesstt This specifies the message digest to sign the request. Any digest supported by the OpenSSL dgst 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 (-mdgost94), Ed25519 and Ed448 never use any digest."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This allows an alternative configuration file to be specified. Optional; for a description of the default value, see \"COMMAND SUMMARY\" in openssl(1)."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Specifies the name of the section to use; the default is req."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Sets subject name for new request or supersedes the subject name when processing a certificate request. The arg must be formatted as \"/type0=value0/type1=value1/type2=...\". Special characters may be escaped by \"\\\" (backslash), whitespace is retained. Empty values are permitted, but the corresponding type will not be included in the request. Giving a single \"/\" will lead to an empty sequence of RDNs (a NULL-DN). Multi-valued RDNs can be formed by placing a \"+\" character instead of a \"/\" between the AttributeValueAssertions (AVAs) that specify the members of the set. Example: \"/DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe\""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This option has been deprecated and has no effect."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This option outputs a certificate instead of a certificate request. This is typically used to generate test certificates. It is implied by the -CA option. This option implies the -new flag if -in is not given. If an existing request is specified with the -in option, it is converted to the a certificate; otherwise a request is created from scratch. Unless specified using the -setserial option, a large random number will be used for the serial number. Unless the -copyextensions 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 -addext option."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Specifies the \"CA\" certificate to be used for signing a new certificate and implies use of -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."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Sets the \"CA\" private key to sign a certificate with. The private key must match the public key of the certificate given with -CA. If this option is not provided then the key must be present in the -CA input."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "When -x509 is in use this specifies the number of days to certify the certificate for, otherwise it is ignored. n should be a positive integer. The default is 30 days."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "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 \"0x\". If not given, a large random number will be used."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Determines how X.509 extensions in certificate requests should be handled when -x509 is in use. If arg is none or this option is not present then extensions are ignored. If arg is copy or copyall 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."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Add a specific extension to the certificate (if -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."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "These options specify alternative sections to include certificate extensions (if -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."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "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 -new flag."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "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."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Customise the printing format used with -text. The option argument can be a single option or multiple options separated by commas. See discussion of the -certopt parameter in the openssl-x509(1) command."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Adds the word NEW to the PEM file header and footer lines on the outputted request. Some software (Netscape certificate server) and some CAs need this."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Non-interactive mode."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Print extra details about the operations being performed."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "Specifies an engine (by its unique id string) which would be used for key generation operations."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "This specifies how the subject or issuer names are displayed. See openssl-namedisplay-options(1) for details."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "See \"Random State Options\" in openssl(1) for details."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "See \"Engine Options\" in openssl(1). This option is deprecated."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "See \"Provider Options\" in openssl(1), provider(7), and property(7)."
        }
    ],
    "examples": [
        "Examine and verify certificate request:",
        "openssl req -in req.pem -text -verify -noout",
        "Create a private key and then generate a certificate request from it:",
        "openssl genrsa -out key.pem 2048",
        "openssl req -new -key key.pem -out req.pem",
        "The same but just using req:",
        "openssl req -newkey rsa:2048 -keyout key.pem -out req.pem",
        "Generate a self-signed root certificate:",
        "openssl req -x509 -newkey rsa:2048 -keyout key.pem -out req.pem",
        "Create an SM2 private key and then generate a certificate request from it:",
        "openssl ecparam -genkey -name SM2 -out sm2.key",
        "openssl req -new -key sm2.key -out sm2.csr -sm3 -sigopt \"distid:1234567812345678\"",
        "Examine and verify an SM2 certificate request:",
        "openssl req -verify -in sm2.csr -sm3 -vfyopt \"distid:1234567812345678\"",
        "Example of a file pointed to by the oidfile option:",
        "1.2.3.4        shortName       A longer Name",
        "1.2.3.6        otherName       Other longer Name",
        "Example of a section pointed to by oidsection making use of variable expansion:",
        "testoid1=1.2.3.5",
        "testoid2=${testoid1}.6",
        "Sample configuration file prompting for field values:",
        "[ req ]",
        "defaultbits           = 2048",
        "defaultkeyfile        = privkey.pem",
        "distinguishedname     = reqdistinguishedname",
        "attributes             = reqattributes",
        "reqextensions         = v3ca",
        "dirstringtype = nobmp",
        "[ reqdistinguishedname ]",
        "countryName                    = Country Name (2 letter code)",
        "countryNamedefault            = AU",
        "countryNamemin                = 2",
        "countryNamemax                = 2",
        "localityName                   = Locality Name (eg, city)",
        "organizationalUnitName         = Organizational Unit Name (eg, section)",
        "commonName                     = Common Name (eg, YOUR name)",
        "commonNamemax                 = 64",
        "emailAddress                   = Email Address",
        "emailAddressmax               = 40",
        "[ reqattributes ]",
        "challengePassword              = A challenge password",
        "challengePasswordmin          = 4",
        "challengePasswordmax          = 20",
        "[ v3ca ]",
        "subjectKeyIdentifier=hash",
        "authorityKeyIdentifier=keyid:always,issuer:always",
        "basicConstraints = critical, CA:true",
        "Sample configuration containing all field values:",
        "[ req ]",
        "defaultbits           = 2048",
        "defaultkeyfile        = keyfile.pem",
        "distinguishedname     = reqdistinguishedname",
        "attributes             = reqattributes",
        "prompt                 = no",
        "outputpassword        = mypass",
        "[ reqdistinguishedname ]",
        "C                      = GB",
        "ST                     = Test State or Province",
        "L                      = Test Locality",
        "O                      = Organization Name",
        "OU                     = Organizational Unit Name",
        "CN                     = Common Name",
        "emailAddress           = test@email.address",
        "[ reqattributes ]",
        "challengePassword              = A challenge password",
        "Example of giving the most common attributes (subject and extensions) on the command line:",
        "openssl req -new -subj \"/C=GB/CN=foo\" \\",
        "-addext \"subjectAltName = DNS:foo.co.uk\" \\",
        "-addext \"certificatePolicies = 1.2.3.4\" \\",
        "-newkey rsa:2048 -keyout key.pem -out req.pem"
    ],
    "see_also": [
        {
            "name": "openssl",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/openssl/1/json"
        },
        {
            "name": "openssl-x509",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/openssl-x509/1/json"
        },
        {
            "name": "openssl-ca",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/openssl-ca/1/json"
        },
        {
            "name": "openssl-genrsa",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/openssl-genrsa/1/json"
        },
        {
            "name": "openssl-gendsa",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/openssl-gendsa/1/json"
        },
        {
            "name": "config",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/config/5/json"
        },
        {
            "name": "x509v3config",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/x509v3config/5/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Manage PKCS#10 Certificate Signing Requests.",
        "examples": [
            {
                "description": "Generate a certificate signing request to be sent to a certificate authority",
                "command": "openssl req -new -sha256 -key {{filename.key}} -out {{filename.csr}}"
            },
            {
                "description": "Generate a self-signed certificate and a corresponding key-pair, storing both in a file",
                "command": "openssl req -new -x509 -newkey {{rsa}}:{{4096}} -keyout {{filename.key}} -out {{filename.cert}} -subj \"{{/C=XX/CN=foobar}}\" -days {{365}}"
            }
        ]
    }
}