openssl-req.1ossl 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "OPENSSL-REQ 1ossl"
  58. .TH OPENSSL-REQ 1ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. openssl\-req \- PKCS#10 certificate request and certificate generating command
  65. .SH SYNOPSIS
  66. .IX Header "SYNOPSIS"
  67. \&\fBopenssl\fR \fBreq\fR
  68. [\fB\-help\fR]
  69. [\fB\-inform\fR \fBDER\fR|\fBPEM\fR]
  70. [\fB\-outform\fR \fBDER\fR|\fBPEM\fR]
  71. [\fB\-in\fR \fIfilename\fR]
  72. [\fB\-passin\fR \fIarg\fR]
  73. [\fB\-out\fR \fIfilename\fR]
  74. [\fB\-passout\fR \fIarg\fR]
  75. [\fB\-text\fR]
  76. [\fB\-pubkey\fR]
  77. [\fB\-noout\fR]
  78. [\fB\-verify\fR]
  79. [\fB\-modulus\fR]
  80. [\fB\-new\fR]
  81. [\fB\-newkey\fR \fIarg\fR]
  82. [\fB\-pkeyopt\fR \fIopt\fR:\fIvalue\fR]
  83. [\fB\-noenc\fR]
  84. [\fB\-nodes\fR]
  85. [\fB\-key\fR \fIfilename\fR|\fIuri\fR]
  86. [\fB\-keyform\fR \fBDER\fR|\fBPEM\fR|\fBP12\fR|\fBENGINE\fR]
  87. [\fB\-keyout\fR \fIfilename\fR]
  88. [\fB\-keygen_engine\fR \fIid\fR]
  89. [\fB\-\fR\f(BIdigest\fR]
  90. [\fB\-config\fR \fIfilename\fR]
  91. [\fB\-section\fR \fIname\fR]
  92. [\fB\-x509\fR]
  93. [\fB\-x509v1\fR]
  94. [\fB\-CA\fR \fIfilename\fR|\fIuri\fR]
  95. [\fB\-CAkey\fR \fIfilename\fR|\fIuri\fR]
  96. [\fB\-not_before\fR \fIdate\fR]
  97. [\fB\-not_after\fR \fIdate\fR]
  98. [\fB\-days\fR \fIn\fR]
  99. [\fB\-set_serial\fR \fIn\fR]
  100. [\fB\-newhdr\fR]
  101. [\fB\-copy_extensions\fR \fIarg\fR]
  102. [\fB\-extensions\fR \fIsection\fR]
  103. [\fB\-reqexts\fR \fIsection\fR]
  104. [\fB\-addext\fR \fIext\fR]
  105. [\fB\-precert\fR]
  106. [\fB\-utf8\fR]
  107. [\fB\-reqopt\fR]
  108. [\fB\-subject\fR]
  109. [\fB\-subj\fR \fIarg\fR]
  110. [\fB\-multivalue\-rdn\fR]
  111. [\fB\-sigopt\fR \fInm\fR:\fIv\fR]
  112. [\fB\-vfyopt\fR \fInm\fR:\fIv\fR]
  113. [\fB\-batch\fR]
  114. [\fB\-verbose\fR]
  115. [\fB\-quiet\fR]
  116. [\fB\-nameopt\fR \fIoption\fR]
  117. [\fB\-rand\fR \fIfiles\fR]
  118. [\fB\-writerand\fR \fIfile\fR]
  119. [\fB\-engine\fR \fIid\fR]
  120. [\fB\-provider\fR \fIname\fR]
  121. [\fB\-provider\-path\fR \fIpath\fR]
  122. [\fB\-propquery\fR \fIpropq\fR]
  123. .SH DESCRIPTION
  124. .IX Header "DESCRIPTION"
  125. This command primarily creates and processes certificate requests (CSRs)
  126. in PKCS#10 format. It can additionally create self-signed certificates
  127. for use as root CAs for example.
  128. .SH OPTIONS
  129. .IX Header "OPTIONS"
  130. .IP \fB\-help\fR 4
  131. .IX Item "-help"
  132. Print out a usage message.
  133. .IP "\fB\-inform\fR \fBDER\fR|\fBPEM\fR" 4
  134. .IX Item "-inform DER|PEM"
  135. The CSR input file format to use; by default PEM is tried first.
  136. See \fBopenssl\-format\-options\fR\|(1) for details.
  137. .IP "\fB\-outform\fR \fBDER\fR|\fBPEM\fR" 4
  138. .IX Item "-outform DER|PEM"
  139. The output format; unspecified by default.
  140. See \fBopenssl\-format\-options\fR\|(1) for details.
  141. .Sp
  142. The data is a PKCS#10 object.
  143. .IP "\fB\-in\fR \fIfilename\fR" 4
  144. .IX Item "-in filename"
  145. This specifies the input filename to read a request from.
  146. This defaults to standard input unless \fB\-x509\fR or \fB\-CA\fR is specified.
  147. A request is only read if the creation options
  148. (\fB\-new\fR or \fB\-newkey\fR or \fB\-precert\fR) are not specified.
  149. .IP "\fB\-sigopt\fR \fInm\fR:\fIv\fR" 4
  150. .IX Item "-sigopt nm:v"
  151. Pass options to the signature algorithm during sign operations.
  152. Names and values of these options are algorithm-specific.
  153. .IP "\fB\-vfyopt\fR \fInm\fR:\fIv\fR" 4
  154. .IX Item "-vfyopt nm:v"
  155. Pass options to the signature algorithm during verify operations.
  156. Names and values of these options are algorithm-specific.
  157. .IP "\fB\-passin\fR \fIarg\fR" 4
  158. .IX Item "-passin arg"
  159. The password source for private key and certificate input.
  160. For more information about the format of \fBarg\fR
  161. see \fBopenssl\-passphrase\-options\fR\|(1).
  162. .IP "\fB\-passout\fR \fIarg\fR" 4
  163. .IX Item "-passout arg"
  164. The password source for the output file.
  165. For more information about the format of \fBarg\fR
  166. see \fBopenssl\-passphrase\-options\fR\|(1).
  167. .IP "\fB\-out\fR \fIfilename\fR" 4
  168. .IX Item "-out filename"
  169. This specifies the output filename to write to or standard output by default.
  170. .IP \fB\-text\fR 4
  171. .IX Item "-text"
  172. Prints out the certificate request in text form.
  173. .IP \fB\-subject\fR 4
  174. .IX Item "-subject"
  175. Prints out the certificate request subject
  176. (or certificate subject if \fB\-x509\fR is in use).
  177. .IP \fB\-pubkey\fR 4
  178. .IX Item "-pubkey"
  179. Prints out the public key.
  180. .IP \fB\-noout\fR 4
  181. .IX Item "-noout"
  182. This option prevents output of the encoded version of the certificate request.
  183. .IP \fB\-modulus\fR 4
  184. .IX Item "-modulus"
  185. Prints out the value of the modulus of the public key contained in the request.
  186. .IP \fB\-verify\fR 4
  187. .IX Item "-verify"
  188. Verifies the self-signature on the request. If the verification fails,
  189. the program will immediately exit, i.e. further option processing
  190. (e.g. \fB\-text\fR) is skipped.
  191. .IP \fB\-new\fR 4
  192. .IX Item "-new"
  193. This option generates a new certificate request. It will prompt
  194. the user for the relevant field values. The actual fields
  195. prompted for and their maximum and minimum sizes are specified
  196. in the configuration file and any requested extensions.
  197. .Sp
  198. If the \fB\-key\fR option is not given it will generate a new private key
  199. using information specified in the configuration file or given with
  200. the \fB\-newkey\fR and \fB\-pkeyopt\fR options,
  201. else by default an RSA key with 2048 bits length.
  202. .IP "\fB\-newkey\fR \fIarg\fR" 4
  203. .IX Item "-newkey arg"
  204. This option is used to generate a new private key unless \fB\-key\fR is given.
  205. It is subsequently used as if it was given using the \fB\-key\fR option.
  206. .Sp
  207. This option implies the \fB\-new\fR flag to create a new certificate request
  208. or a new certificate in case \fB\-x509\fR is used.
  209. .Sp
  210. The argument takes one of several forms.
  211. .Sp
  212. [\fBrsa:\fR]\fInbits\fR generates an RSA key \fInbits\fR in size.
  213. If \fInbits\fR is omitted, i.e., \fB\-newkey\fR \fBrsa\fR is specified,
  214. the default key size specified in the configuration file
  215. with the \fBdefault_bits\fR option is used if present, else 2048.
  216. .Sp
  217. All other algorithms support the \fB\-newkey\fR \fIalgname\fR:\fIfile\fR form, where
  218. \&\fIfile\fR is an algorithm parameter file, created with \f(CW\*(C`openssl genpkey \-genparam\*(C'\fR
  219. or an X.509 certificate for a key with appropriate algorithm.
  220. .Sp
  221. \&\fBparam:\fR\fIfile\fR generates a key using the parameter file or certificate
  222. \&\fIfile\fR, the algorithm is determined by the parameters.
  223. .Sp
  224. \&\fIalgname\fR[:\fIfile\fR] generates a key using the given algorithm \fIalgname\fR.
  225. If a parameter file \fIfile\fR is given then the parameters specified there
  226. are used, where the algorithm parameters must match \fIalgname\fR.
  227. If algorithm parameters are not given,
  228. any necessary parameters should be specified via the \fB\-pkeyopt\fR option.
  229. .Sp
  230. \&\fBdsa:\fR\fIfilename\fR generates a DSA key using the parameters
  231. in the file \fIfilename\fR. \fBec:\fR\fIfilename\fR generates EC key (usable both with
  232. ECDSA or ECDH algorithms), \fBgost2001:\fR\fIfilename\fR generates GOST R
  233. 34.10\-2001 key (requires \fBgost\fR engine configured in the configuration
  234. file). If just \fBgost2001\fR is specified a parameter set should be
  235. specified by \fB\-pkeyopt\fR \fIparamset:X\fR
  236. .IP "\fB\-pkeyopt\fR \fIopt\fR:\fIvalue\fR" 4
  237. .IX Item "-pkeyopt opt:value"
  238. Set the public key algorithm option \fIopt\fR to \fIvalue\fR. The precise set of
  239. options supported depends on the public key algorithm used and its
  240. implementation.
  241. See "KEY GENERATION OPTIONS" in \fBopenssl\-genpkey\fR\|(1) for more details.
  242. .IP "\fB\-key\fR \fIfilename\fR|\fIuri\fR" 4
  243. .IX Item "-key filename|uri"
  244. This option provides the private key for signing a new certificate or
  245. certificate request.
  246. Unless \fB\-in\fR is given, the corresponding public key is placed in
  247. the new certificate or certificate request, resulting in a self-signature.
  248. .Sp
  249. For certificate signing this option is overridden by the \fB\-CA\fR option.
  250. .Sp
  251. This option also accepts PKCS#8 format private keys for PEM format files.
  252. .IP "\fB\-keyform\fR \fBDER\fR|\fBPEM\fR|\fBP12\fR|\fBENGINE\fR" 4
  253. .IX Item "-keyform DER|PEM|P12|ENGINE"
  254. The format of the private key; unspecified by default.
  255. See \fBopenssl\-format\-options\fR\|(1) for details.
  256. .IP "\fB\-keyout\fR \fIfilename\fR" 4
  257. .IX Item "-keyout filename"
  258. This gives the filename to write any private key to that has been newly created
  259. or read from \fB\-key\fR. If neither the \fB\-keyout\fR option nor the \fB\-key\fR option
  260. are given then the filename specified in the configuration file with the
  261. \&\fBdefault_keyfile\fR option is used, if present. Thus, if you want to write the
  262. private key and the \fB\-key\fR option is provided, you should provide the
  263. \&\fB\-keyout\fR option explicitly. If a new key is generated and no filename is
  264. specified the key is written to standard output.
  265. .IP \fB\-noenc\fR 4
  266. .IX Item "-noenc"
  267. If this option is specified then if a private key is created it
  268. will not be encrypted.
  269. .IP \fB\-nodes\fR 4
  270. .IX Item "-nodes"
  271. This option is deprecated since OpenSSL 3.0; use \fB\-noenc\fR instead.
  272. .IP \fB\-\fR\f(BIdigest\fR 4
  273. .IX Item "-digest"
  274. This specifies the message digest to sign the request.
  275. Any digest supported by the OpenSSL \fBdgst\fR command can be used.
  276. This overrides the digest algorithm specified in
  277. the configuration file.
  278. .Sp
  279. Some public key algorithms may override this choice. For instance, DSA
  280. signatures always use SHA1, GOST R 34.10 signatures always use
  281. GOST R 34.11\-94 (\fB\-md_gost94\fR), Ed25519 and Ed448 never use any digest.
  282. .IP "\fB\-config\fR \fIfilename\fR" 4
  283. .IX Item "-config filename"
  284. This allows an alternative configuration file to be specified.
  285. Optional; for a description of the default value,
  286. see "COMMAND SUMMARY" in \fBopenssl\fR\|(1).
  287. .IP "\fB\-section\fR \fIname\fR" 4
  288. .IX Item "-section name"
  289. Specifies the name of the section to use; the default is \fBreq\fR.
  290. .IP "\fB\-subj\fR \fIarg\fR" 4
  291. .IX Item "-subj arg"
  292. Sets subject name for new request or supersedes the subject name
  293. when processing a certificate request.
  294. .Sp
  295. The arg must be formatted as \f(CW\*(C`/type0=value0/type1=value1/type2=...\*(C'\fR.
  296. Special characters may be escaped by \f(CW\*(C`\e\*(C'\fR (backslash), whitespace is retained.
  297. Empty values are permitted, but the corresponding type will not be included
  298. in the request.
  299. Giving a single \f(CW\*(C`/\*(C'\fR will lead to an empty sequence of RDNs (a NULL-DN).
  300. Multi-valued RDNs can be formed by placing a \f(CW\*(C`+\*(C'\fR character instead of a \f(CW\*(C`/\*(C'\fR
  301. between the AttributeValueAssertions (AVAs) that specify the members of the set.
  302. Example:
  303. .Sp
  304. \&\f(CW\*(C`/DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe\*(C'\fR
  305. .IP \fB\-multivalue\-rdn\fR 4
  306. .IX Item "-multivalue-rdn"
  307. This option has been deprecated and has no effect.
  308. .IP \fB\-x509\fR 4
  309. .IX Item "-x509"
  310. This option outputs a certificate instead of a certificate request.
  311. This is typically used to generate test certificates.
  312. It is implied by the \fB\-CA\fR option.
  313. .Sp
  314. This option implies the \fB\-new\fR flag if \fB\-in\fR is not given.
  315. .Sp
  316. If an existing request is specified with the \fB\-in\fR option, it is converted
  317. to a certificate; otherwise a request is created from scratch.
  318. .Sp
  319. Unless specified using the \fB\-set_serial\fR option,
  320. a large random number will be used for the serial number.
  321. .Sp
  322. Unless the \fB\-copy_extensions\fR option is used,
  323. X.509 extensions are not copied from any provided request input file.
  324. .Sp
  325. X.509 extensions to be added can be specified in the configuration file,
  326. possibly using the \fB\-config\fR and \fB\-extensions\fR options,
  327. and/or using the \fB\-addext\fR option.
  328. .Sp
  329. Unless \fB\-x509v1\fR is given, generated certificates bear X.509 version 3.
  330. Unless specified otherwise,
  331. key identifier extensions are included as described in \fBx509v3_config\fR\|(5).
  332. .IP \fB\-x509v1\fR 4
  333. .IX Item "-x509v1"
  334. Request generation of certificates with X.509 version 1.
  335. This implies \fB\-x509\fR.
  336. If X.509 extensions are given, anyway X.509 version 3 is set.
  337. .IP "\fB\-CA\fR \fIfilename\fR|\fIuri\fR" 4
  338. .IX Item "-CA filename|uri"
  339. Specifies the "CA" certificate to be used for signing a new certificate
  340. and implies use of \fB\-x509\fR.
  341. When present, this behaves like a "micro CA" as follows:
  342. The subject name of the "CA" certificate is placed as issuer name in the new
  343. certificate, which is then signed using the "CA" key given as specified below.
  344. .IP "\fB\-CAkey\fR \fIfilename\fR|\fIuri\fR" 4
  345. .IX Item "-CAkey filename|uri"
  346. Sets the "CA" private key to sign a certificate with.
  347. The private key must match the public key of the certificate given with \fB\-CA\fR.
  348. If this option is not provided then the key must be present in the \fB\-CA\fR input.
  349. .IP "\fB\-not_before\fR \fIdate\fR" 4
  350. .IX Item "-not_before date"
  351. When \fB\-x509\fR is in use this allows the start date to be explicitly set,
  352. otherwise it is ignored. The format of \fIdate\fR is YYMMDDHHMMSSZ (the
  353. same as an ASN1 UTCTime structure), or YYYYMMDDHHMMSSZ (the same as an
  354. ASN1 GeneralizedTime structure). In both formats, seconds SS and
  355. timezone Z must be present.
  356. Alternatively, you can also use "today".
  357. .IP "\fB\-not_after\fR \fIdate\fR" 4
  358. .IX Item "-not_after date"
  359. When \fB\-x509\fR is in use this allows the expiry date to be explicitly
  360. set, otherwise it is ignored. The format of \fIdate\fR is YYMMDDHHMMSSZ
  361. (the same as an ASN1 UTCTime structure), or YYYYMMDDHHMMSSZ (the same as
  362. an ASN1 GeneralizedTime structure). In both formats, seconds SS and
  363. timezone Z must be present.
  364. Alternatively, you can also use "today".
  365. .Sp
  366. This overrides the \fB\-days\fR option.
  367. .IP "\fB\-days\fR \fIn\fR" 4
  368. .IX Item "-days n"
  369. When \fB\-x509\fR is in use this specifies the number of days from today to
  370. certify the certificate for, otherwise it is ignored. \fIn\fR should
  371. be a positive integer. The default is 30 days.
  372. .Sp
  373. Regardless of the option \fB\-not_before\fR, the days are always counted from
  374. today.
  375. When used together with the option \fB\-not_after\fR, the explicit expiry
  376. date takes precedence.
  377. .IP "\fB\-set_serial\fR \fIn\fR" 4
  378. .IX Item "-set_serial n"
  379. Serial number to use when outputting a self-signed certificate.
  380. This may be specified as a decimal value or a hex value if preceded by \f(CW\*(C`0x\*(C'\fR.
  381. If not given, a large random number will be used.
  382. .IP "\fB\-copy_extensions\fR \fIarg\fR" 4
  383. .IX Item "-copy_extensions arg"
  384. Determines how X.509 extensions in certificate requests should be handled
  385. when \fB\-x509\fR is in use.
  386. If \fIarg\fR is \fBnone\fR or this option is not present then extensions are ignored.
  387. If \fIarg\fR is \fBcopy\fR or \fBcopyall\fR then
  388. all extensions in the request are copied to the certificate.
  389. .Sp
  390. The main use of this option is to allow a certificate request to supply
  391. values for certain extensions such as subjectAltName.
  392. .IP "\fB\-extensions\fR \fIsection\fR, \fB\-reqexts\fR \fIsection\fR" 4
  393. .IX Item "-extensions section, -reqexts section"
  394. Can be used to override the name of the configuration file section
  395. from which X.509 extensions are included
  396. in the certificate (when \fB\-x509\fR is in use) or certificate request.
  397. This allows several different sections to be used in the same configuration
  398. file to specify requests for a variety of purposes.
  399. .IP "\fB\-addext\fR \fIext\fR" 4
  400. .IX Item "-addext ext"
  401. Add a specific extension to the certificate (if \fB\-x509\fR is in use)
  402. or certificate request. The argument must have the form of
  403. a \f(CW\*(C`key=value\*(C'\fR pair as it would appear in a config file.
  404. .Sp
  405. If an extension is added using this option that has the same OID as one
  406. defined in the extension section of the config file, it overrides that one.
  407. .Sp
  408. This option can be given multiple times.
  409. Doing so, the same key most not be given more than once.
  410. .IP \fB\-precert\fR 4
  411. .IX Item "-precert"
  412. A poison extension will be added to the certificate, making it a
  413. "pre-certificate" (see RFC6962). This can be submitted to Certificate
  414. Transparency logs in order to obtain signed certificate timestamps (SCTs).
  415. These SCTs can then be embedded into the pre-certificate as an extension, before
  416. removing the poison and signing the certificate.
  417. .Sp
  418. This implies the \fB\-new\fR flag.
  419. .IP \fB\-utf8\fR 4
  420. .IX Item "-utf8"
  421. This option causes field values to be interpreted as UTF8 strings, by
  422. default they are interpreted as ASCII. This means that the field
  423. values, whether prompted from a terminal or obtained from a
  424. configuration file, must be valid UTF8 strings.
  425. .IP "\fB\-reqopt\fR \fIoption\fR" 4
  426. .IX Item "-reqopt option"
  427. Customise the printing format used with \fB\-text\fR. The \fIoption\fR argument can be
  428. a single option or multiple options separated by commas.
  429. .Sp
  430. See discussion of the \fB\-certopt\fR parameter in the \fBopenssl\-x509\fR\|(1)
  431. command.
  432. .IP \fB\-newhdr\fR 4
  433. .IX Item "-newhdr"
  434. Adds the word \fBNEW\fR to the PEM file header and footer lines on the outputted
  435. request. Some software (Netscape certificate server) and some CAs need this.
  436. .IP \fB\-batch\fR 4
  437. .IX Item "-batch"
  438. Non-interactive mode.
  439. .IP \fB\-verbose\fR 4
  440. .IX Item "-verbose"
  441. Print extra details about the operations being performed.
  442. .IP \fB\-quiet\fR 4
  443. .IX Item "-quiet"
  444. Print fewer details about the operations being performed, which may be
  445. handy during batch scripts or pipelines (specifically "progress dots"
  446. during key generation are suppressed).
  447. .IP "\fB\-keygen_engine\fR \fIid\fR" 4
  448. .IX Item "-keygen_engine id"
  449. Specifies an engine (by its unique \fIid\fR string) which would be used
  450. for key generation operations.
  451. .IP "\fB\-nameopt\fR \fIoption\fR" 4
  452. .IX Item "-nameopt option"
  453. This specifies how the subject or issuer names are displayed.
  454. See \fBopenssl\-namedisplay\-options\fR\|(1) for details.
  455. .IP "\fB\-rand\fR \fIfiles\fR, \fB\-writerand\fR \fIfile\fR" 4
  456. .IX Item "-rand files, -writerand file"
  457. See "Random State Options" in \fBopenssl\fR\|(1) for details.
  458. .IP "\fB\-engine\fR \fIid\fR" 4
  459. .IX Item "-engine id"
  460. See "Engine Options" in \fBopenssl\fR\|(1).
  461. This option is deprecated.
  462. .IP "\fB\-provider\fR \fIname\fR" 4
  463. .IX Item "-provider name"
  464. .PD 0
  465. .IP "\fB\-provider\-path\fR \fIpath\fR" 4
  466. .IX Item "-provider-path path"
  467. .IP "\fB\-propquery\fR \fIpropq\fR" 4
  468. .IX Item "-propquery propq"
  469. .PD
  470. See "Provider Options" in \fBopenssl\fR\|(1), \fBprovider\fR\|(7), and \fBproperty\fR\|(7).
  471. .SH "CONFIGURATION FILE FORMAT"
  472. .IX Header "CONFIGURATION FILE FORMAT"
  473. The configuration options are specified in the \fBreq\fR section of
  474. the configuration file. An alternate name be specified by using the
  475. \&\fB\-section\fR option.
  476. As with all configuration files, if no
  477. value is specified in the specific section then
  478. the initial unnamed or \fBdefault\fR section is searched too.
  479. .PP
  480. The options available are described in detail below.
  481. .IP "\fBinput_password\fR, \fBoutput_password\fR" 4
  482. .IX Item "input_password, output_password"
  483. The passwords for the input private key file (if present) and
  484. the output private key file (if one will be created). The
  485. command line options \fBpassin\fR and \fBpassout\fR override the
  486. configuration file values.
  487. .IP \fBdefault_bits\fR 4
  488. .IX Item "default_bits"
  489. Specifies the default key size in bits.
  490. .Sp
  491. This option is used in conjunction with the \fB\-new\fR option to generate
  492. a new key. It can be overridden by specifying an explicit key size in
  493. the \fB\-newkey\fR option. The smallest accepted key size is 512 bits. If
  494. no key size is specified then 2048 bits is used.
  495. .IP \fBdefault_keyfile\fR 4
  496. .IX Item "default_keyfile"
  497. This is the default filename to write a private key to. If not
  498. specified the key is written to standard output. This can be
  499. overridden by the \fB\-keyout\fR option.
  500. .IP \fBoid_file\fR 4
  501. .IX Item "oid_file"
  502. This specifies a file containing additional \fBOBJECT IDENTIFIERS\fR.
  503. Each line of the file should consist of the numerical form of the
  504. object identifier followed by whitespace then the short name followed
  505. by whitespace and finally the long name.
  506. .IP \fBoid_section\fR 4
  507. .IX Item "oid_section"
  508. This specifies a section in the configuration file containing extra
  509. object identifiers. Each line should consist of the short name of the
  510. object identifier followed by \fB=\fR and the numerical form. The short
  511. and long names are the same when this option is used.
  512. .IP \fBRANDFILE\fR 4
  513. .IX Item "RANDFILE"
  514. At startup the specified file is loaded into the random number generator,
  515. and at exit 256 bytes will be written to it.
  516. It is used for private key generation.
  517. .IP \fBencrypt_key\fR 4
  518. .IX Item "encrypt_key"
  519. If this is set to \fBno\fR then if a private key is generated it is
  520. \&\fBnot\fR encrypted. This is equivalent to the \fB\-noenc\fR command line
  521. option. For compatibility \fBencrypt_rsa_key\fR is an equivalent option.
  522. .IP \fBdefault_md\fR 4
  523. .IX Item "default_md"
  524. This option specifies the digest algorithm to use. Any digest supported by the
  525. OpenSSL \fBdgst\fR command can be used. This option can be overridden on the
  526. command line. Certain signing algorithms (i.e. Ed25519 and Ed448) will ignore
  527. any digest that has been set.
  528. .IP \fBstring_mask\fR 4
  529. .IX Item "string_mask"
  530. This option masks out the use of certain string types in certain
  531. fields. Most users will not need to change this option. It can be set to
  532. several values:
  533. .RS 4
  534. .IP "\fButf8only\fR \- only UTF8Strings are used (this is the default value)" 4
  535. .IX Item "utf8only - only UTF8Strings are used (this is the default value)"
  536. .PD 0
  537. .IP "\fBpkix\fR \- any string type except T61Strings" 4
  538. .IX Item "pkix - any string type except T61Strings"
  539. .IP "\fBnombstr\fR \- any string type except BMPStrings and UTF8Strings" 4
  540. .IX Item "nombstr - any string type except BMPStrings and UTF8Strings"
  541. .IP "\fBdefault\fR \- any kind of string type" 4
  542. .IX Item "default - any kind of string type"
  543. .RE
  544. .RS 4
  545. .PD
  546. .Sp
  547. Note that \fButf8only\fR is the PKIX recommendation in RFC2459 after 2003, and the
  548. default \fBstring_mask\fR; \fBdefault\fR is not the default option. The \fBnombstr\fR
  549. value is a workaround for some software that has problems with variable-sized
  550. BMPStrings and UTF8Strings.
  551. .RE
  552. .IP \fBreq_extensions\fR 4
  553. .IX Item "req_extensions"
  554. This specifies the configuration file section containing a list of
  555. extensions to add to the certificate request. It can be overridden
  556. by the \fB\-reqexts\fR (or \fB\-extensions\fR) command line switch. See the
  557. \&\fBx509v3_config\fR\|(5) manual page for details of the
  558. extension section format.
  559. .IP \fBx509_extensions\fR 4
  560. .IX Item "x509_extensions"
  561. This specifies the configuration file section containing a list of
  562. extensions to add to certificate generated when \fB\-x509\fR is in use.
  563. It can be overridden by the \fB\-extensions\fR command line switch.
  564. .IP \fBprompt\fR 4
  565. .IX Item "prompt"
  566. If set to the value \fBno\fR this disables prompting of certificate fields
  567. and just takes values from the config file directly. It also changes the
  568. expected format of the \fBdistinguished_name\fR and \fBattributes\fR sections.
  569. .IP \fButf8\fR 4
  570. .IX Item "utf8"
  571. If set to the value \fByes\fR then field values to be interpreted as UTF8
  572. strings, by default they are interpreted as ASCII. This means that
  573. the field values, whether prompted from a terminal or obtained from a
  574. configuration file, must be valid UTF8 strings.
  575. .IP \fBattributes\fR 4
  576. .IX Item "attributes"
  577. This specifies the section containing any request attributes: its format
  578. is the same as \fBdistinguished_name\fR. Typically these may contain the
  579. challengePassword or unstructuredName types. They are currently ignored
  580. by OpenSSL's request signing utilities but some CAs might want them.
  581. .IP \fBdistinguished_name\fR 4
  582. .IX Item "distinguished_name"
  583. This specifies the section containing the distinguished name fields to
  584. prompt for when generating a certificate or certificate request. The format
  585. is described in the next section.
  586. .SH "DISTINGUISHED NAME AND ATTRIBUTE SECTION FORMAT"
  587. .IX Header "DISTINGUISHED NAME AND ATTRIBUTE SECTION FORMAT"
  588. There are two separate formats for the distinguished name and attribute
  589. sections. If the \fBprompt\fR option is set to \fBno\fR then these sections
  590. just consist of field names and values: for example,
  591. .PP
  592. .Vb 3
  593. \& CN=My Name
  594. \& OU=My Organization
  595. \& emailAddress=someone@somewhere.org
  596. .Ve
  597. .PP
  598. This allows external programs (e.g. GUI based) to generate a template file with
  599. all the field names and values and just pass it to this command. An example
  600. of this kind of configuration file is contained in the \fBEXAMPLES\fR section.
  601. .PP
  602. Alternatively if the \fBprompt\fR option is absent or not set to \fBno\fR then the
  603. file contains field prompting information. It consists of lines of the form:
  604. .PP
  605. .Vb 4
  606. \& fieldName="prompt"
  607. \& fieldName_default="default field value"
  608. \& fieldName_min= 2
  609. \& fieldName_max= 4
  610. .Ve
  611. .PP
  612. "fieldName" is the field name being used, for example commonName (or CN).
  613. The "prompt" string is used to ask the user to enter the relevant
  614. details. If the user enters nothing then the default value is used if no
  615. default value is present then the field is omitted. A field can
  616. still be omitted if a default value is present if the user just
  617. enters the '.' character.
  618. .PP
  619. The number of characters entered must be between the fieldName_min and
  620. fieldName_max limits: there may be additional restrictions based
  621. on the field being used (for example countryName can only ever be
  622. two characters long and must fit in a PrintableString).
  623. .PP
  624. Some fields (such as organizationName) can be used more than once
  625. in a DN. This presents a problem because configuration files will
  626. not recognize the same name occurring twice. To avoid this problem
  627. if the fieldName contains some characters followed by a full stop
  628. they will be ignored. So for example a second organizationName can
  629. be input by calling it "1.organizationName".
  630. .PP
  631. The actual permitted field names are any object identifier short or
  632. long names. These are compiled into OpenSSL and include the usual
  633. values such as commonName, countryName, localityName, organizationName,
  634. organizationalUnitName, stateOrProvinceName. Additionally emailAddress
  635. is included as well as name, surname, givenName, initials, and dnQualifier.
  636. .PP
  637. Additional object identifiers can be defined with the \fBoid_file\fR or
  638. \&\fBoid_section\fR options in the configuration file. Any additional fields
  639. will be treated as though they were a DirectoryString.
  640. .SH EXAMPLES
  641. .IX Header "EXAMPLES"
  642. Examine and verify certificate request:
  643. .PP
  644. .Vb 1
  645. \& openssl req \-in req.pem \-text \-verify \-noout
  646. .Ve
  647. .PP
  648. Create a private key and then generate a certificate request from it:
  649. .PP
  650. .Vb 2
  651. \& openssl genrsa \-out key.pem 2048
  652. \& openssl req \-new \-key key.pem \-out req.pem
  653. .Ve
  654. .PP
  655. The same but just using req:
  656. .PP
  657. .Vb 1
  658. \& openssl req \-newkey rsa:2048 \-keyout key.pem \-out req.pem
  659. .Ve
  660. .PP
  661. Generate a self-signed root certificate:
  662. .PP
  663. .Vb 1
  664. \& openssl req \-x509 \-newkey rsa:2048 \-keyout key.pem \-out req.pem
  665. .Ve
  666. .PP
  667. Create an SM2 private key and then generate a certificate request from it:
  668. .PP
  669. .Vb 2
  670. \& openssl ecparam \-genkey \-name SM2 \-out sm2.key
  671. \& openssl req \-new \-key sm2.key \-out sm2.csr \-sm3 \-sigopt "distid:1234567812345678"
  672. .Ve
  673. .PP
  674. Examine and verify an SM2 certificate request:
  675. .PP
  676. .Vb 1
  677. \& openssl req \-verify \-in sm2.csr \-sm3 \-vfyopt "distid:1234567812345678"
  678. .Ve
  679. .PP
  680. Example of a file pointed to by the \fBoid_file\fR option:
  681. .PP
  682. .Vb 2
  683. \& 1.2.3.4 shortName A longer Name
  684. \& 1.2.3.6 otherName Other longer Name
  685. .Ve
  686. .PP
  687. Example of a section pointed to by \fBoid_section\fR making use of variable
  688. expansion:
  689. .PP
  690. .Vb 2
  691. \& testoid1=1.2.3.5
  692. \& testoid2=${testoid1}.6
  693. .Ve
  694. .PP
  695. Sample configuration file prompting for field values:
  696. .PP
  697. .Vb 6
  698. \& [ req ]
  699. \& default_bits = 2048
  700. \& default_keyfile = privkey.pem
  701. \& distinguished_name = req_distinguished_name
  702. \& attributes = req_attributes
  703. \& req_extensions = v3_ca
  704. \&
  705. \& dirstring_type = nobmp
  706. \&
  707. \& [ req_distinguished_name ]
  708. \& countryName = Country Name (2 letter code)
  709. \& countryName_default = AU
  710. \& countryName_min = 2
  711. \& countryName_max = 2
  712. \&
  713. \& localityName = Locality Name (eg, city)
  714. \&
  715. \& organizationalUnitName = Organizational Unit Name (eg, section)
  716. \&
  717. \& commonName = Common Name (eg, YOUR name)
  718. \& commonName_max = 64
  719. \&
  720. \& emailAddress = Email Address
  721. \& emailAddress_max = 40
  722. \&
  723. \& [ req_attributes ]
  724. \& challengePassword = A challenge password
  725. \& challengePassword_min = 4
  726. \& challengePassword_max = 20
  727. \&
  728. \& [ v3_ca ]
  729. \&
  730. \& subjectKeyIdentifier=hash
  731. \& authorityKeyIdentifier=keyid:always,issuer:always
  732. \& basicConstraints = critical, CA:true
  733. .Ve
  734. .PP
  735. Sample configuration containing all field values:
  736. .PP
  737. .Vb 7
  738. \& [ req ]
  739. \& default_bits = 2048
  740. \& default_keyfile = keyfile.pem
  741. \& distinguished_name = req_distinguished_name
  742. \& attributes = req_attributes
  743. \& prompt = no
  744. \& output_password = mypass
  745. \&
  746. \& [ req_distinguished_name ]
  747. \& C = GB
  748. \& ST = Test State or Province
  749. \& L = Test Locality
  750. \& O = Organization Name
  751. \& OU = Organizational Unit Name
  752. \& CN = Common Name
  753. \& emailAddress = test@email.address
  754. \&
  755. \& [ req_attributes ]
  756. \& challengePassword = A challenge password
  757. .Ve
  758. .PP
  759. Example of giving the most common attributes (subject and extensions)
  760. on the command line:
  761. .PP
  762. .Vb 4
  763. \& openssl req \-new \-subj "/C=GB/CN=foo" \e
  764. \& \-addext "subjectAltName = DNS:foo.co.uk" \e
  765. \& \-addext "certificatePolicies = 1.2.3.4" \e
  766. \& \-newkey rsa:2048 \-keyout key.pem \-out req.pem
  767. .Ve
  768. .SH NOTES
  769. .IX Header "NOTES"
  770. The certificate requests generated by \fBXenroll\fR with MSIE have extensions
  771. added. It includes the \fBkeyUsage\fR extension which determines the type of
  772. key (signature only or general purpose) and any additional OIDs entered
  773. by the script in an \fBextendedKeyUsage\fR extension.
  774. .SH DIAGNOSTICS
  775. .IX Header "DIAGNOSTICS"
  776. The following messages are frequently asked about:
  777. .PP
  778. .Vb 2
  779. \& Using configuration from /some/path/openssl.cnf
  780. \& Unable to load config info
  781. .Ve
  782. .PP
  783. This is followed some time later by:
  784. .PP
  785. .Vb 2
  786. \& unable to find \*(Aqdistinguished_name\*(Aq in config
  787. \& problems making Certificate Request
  788. .Ve
  789. .PP
  790. The first error message is the clue: it can't find the configuration
  791. file! Certain operations (like examining a certificate request) don't
  792. need a configuration file so its use isn't enforced. Generation of
  793. certificates or requests however does need a configuration file. This
  794. could be regarded as a bug.
  795. .PP
  796. Another puzzling message is this:
  797. .PP
  798. .Vb 2
  799. \& Attributes:
  800. \& a0:00
  801. .Ve
  802. .PP
  803. this is displayed when no attributes are present and the request includes
  804. the correct empty \fBSET OF\fR structure (the DER encoding of which is 0xa0
  805. 0x00). If you just see:
  806. .PP
  807. .Vb 1
  808. \& Attributes:
  809. .Ve
  810. .PP
  811. then the \fBSET OF\fR is missing and the encoding is technically invalid (but
  812. it is tolerated). See the description of the command line option \fB\-asn1\-kludge\fR
  813. for more information.
  814. .SH BUGS
  815. .IX Header "BUGS"
  816. OpenSSL's handling of T61Strings (aka TeletexStrings) is broken: it effectively
  817. treats them as ISO\-8859\-1 (Latin 1), Netscape and MSIE have similar behaviour.
  818. This can cause problems if you need characters that aren't available in
  819. PrintableStrings and you don't want to or can't use BMPStrings.
  820. .PP
  821. As a consequence of the T61String handling the only correct way to represent
  822. accented characters in OpenSSL is to use a BMPString: unfortunately Netscape
  823. currently chokes on these. If you have to use accented characters with Netscape
  824. and MSIE then you currently need to use the invalid T61String form.
  825. .PP
  826. The current prompting is not very friendly. It doesn't allow you to confirm what
  827. you've just entered. Other things like extensions in certificate requests are
  828. statically defined in the configuration file. Some of these: like an email
  829. address in subjectAltName should be input by the user.
  830. .SH "SEE ALSO"
  831. .IX Header "SEE ALSO"
  832. \&\fBopenssl\fR\|(1),
  833. \&\fBopenssl\-x509\fR\|(1),
  834. \&\fBopenssl\-ca\fR\|(1),
  835. \&\fBopenssl\-genrsa\fR\|(1),
  836. \&\fBopenssl\-gendsa\fR\|(1),
  837. \&\fBconfig\fR\|(5),
  838. \&\fBx509v3_config\fR\|(5)
  839. .SH HISTORY
  840. .IX Header "HISTORY"
  841. The \fB\-section\fR option was added in OpenSSL 3.0.0.
  842. .PP
  843. The \fB\-multivalue\-rdn\fR option has become obsolete in OpenSSL 3.0.0 and
  844. has no effect.
  845. .PP
  846. The \fB\-engine\fR option was deprecated in OpenSSL 3.0.
  847. The <\-nodes> option was deprecated in OpenSSL 3.0, too; use \fB\-noenc\fR instead.
  848. .PP
  849. The \fB\-reqexts\fR option has been made an alias of \fB\-extensions\fR in OpenSSL 3.2.
  850. .PP
  851. Since OpenSSL 3.2,
  852. generated certificates bear X.509 version 3 unless \fB\-x509v1\fR is given,
  853. and key identifier extensions are included by default.
  854. .PP
  855. Since OpenSSL 3.3, the \fB\-verify\fR option will exit with 1 on failure.
  856. .SH COPYRIGHT
  857. .IX Header "COPYRIGHT"
  858. Copyright 2000\-2024 The OpenSSL Project Authors. All Rights Reserved.
  859. .PP
  860. Licensed under the Apache License 2.0 (the "License"). You may not use
  861. this file except in compliance with the License. You can obtain a copy
  862. in the file LICENSE in the source distribution or at
  863. <https://www.openssl.org/source/license.html>.