Debian Codegraph @

upstream/debian-trixie/man1/openssl-x509.1ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
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-X509 1SSL"
58 .TH OPENSSL-X509 1SSL 2026-04-07 3.5.6 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\-x509 \- Certificate display and signing command
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 \&\fBopenssl\fR \fBx509\fR
68 [\fB\-help\fR]
69 [\fB\-in\fR \fIfilename\fR|\fIuri\fR]
70 [\fB\-passin\fR \fIarg\fR]
71 [\fB\-new\fR]
72 [\fB\-x509toreq\fR]
73 [\fB\-req\fR]
74 [\fB\-copy_extensions\fR \fIarg\fR]
75 [\fB\-inform\fR \fBDER\fR|\fBPEM\fR]
76 [\fB\-vfyopt\fR \fInm\fR:\fIv\fR]
77 [\fB\-key\fR \fIfilename\fR|\fIuri\fR]
78 [\fB\-keyform\fR \fBDER\fR|\fBPEM\fR|\fBP12\fR|\fBENGINE\fR]
79 [\fB\-signkey\fR \fIfilename\fR|\fIuri\fR]
80 [\fB\-out\fR \fIfilename\fR]
81 [\fB\-outform\fR \fBDER\fR|\fBPEM\fR]
82 [\fB\-nocert\fR]
83 [\fB\-noout\fR]
84 [\fB\-dateopt\fR]
85 [\fB\-text\fR]
86 [\fB\-certopt\fR \fIoption\fR]
87 [\fB\-fingerprint\fR]
88 [\fB\-alias\fR]
89 [\fB\-serial\fR]
90 [\fB\-startdate\fR]
91 [\fB\-enddate\fR]
92 [\fB\-dates\fR]
93 [\fB\-subject\fR]
94 [\fB\-issuer\fR]
95 [\fB\-nameopt\fR \fIoption\fR]
96 [\fB\-email\fR]
97 [\fB\-hash\fR]
98 [\fB\-subject_hash\fR]
99 [\fB\-subject_hash_old\fR]
100 [\fB\-issuer_hash\fR]
101 [\fB\-issuer_hash_old\fR]
102 [\fB\-ext\fR \fIextensions\fR]
103 [\fB\-ocspid\fR]
104 [\fB\-ocsp_uri\fR]
105 [\fB\-purpose\fR]
106 [\fB\-pubkey\fR]
107 [\fB\-modulus\fR]
108 [\fB\-checkend\fR \fInum\fR]
109 [\fB\-checkhost\fR \fIhost\fR]
110 [\fB\-checkemail\fR \fIhost\fR]
111 [\fB\-checkip\fR \fIipaddr\fR]
112 [\fB\-set_serial\fR \fIn\fR]
113 [\fB\-next_serial\fR]
114 [\fB\-not_before\fR \fIdate\fR]
115 [\fB\-not_after\fR \fIdate\fR]
116 [\fB\-days\fR \fIarg\fR]
117 [\fB\-preserve_dates\fR]
118 [\fB\-set_issuer\fR \fIarg\fR]
119 [\fB\-set_subject\fR \fIarg\fR]
120 [\fB\-subj\fR \fIarg\fR]
121 [\fB\-force_pubkey\fR \fIfilename\fR]
122 [\fB\-clrext\fR]
123 [\fB\-extfile\fR \fIfilename\fR]
124 [\fB\-extensions\fR \fIsection\fR]
125 [\fB\-sigopt\fR \fInm\fR:\fIv\fR]
126 [\fB\-badsig\fR]
127 [\fB\-\fR\f(BIdigest\fR]
128 [\fB\-CA\fR \fIfilename\fR|\fIuri\fR]
129 [\fB\-CAform\fR \fBDER\fR|\fBPEM\fR|\fBP12\fR]
130 [\fB\-CAkey\fR \fIfilename\fR|\fIuri\fR]
131 [\fB\-CAkeyform\fR \fBDER\fR|\fBPEM\fR|\fBP12\fR|\fBENGINE\fR]
132 [\fB\-CAserial\fR \fIfilename\fR]
133 [\fB\-CAcreateserial\fR]
134 [\fB\-trustout\fR]
135 [\fB\-setalias\fR \fIarg\fR]
136 [\fB\-clrtrust\fR]
137 [\fB\-addtrust\fR \fIarg\fR]
138 [\fB\-clrreject\fR]
139 [\fB\-addreject\fR \fIarg\fR]
140 [\fB\-rand\fR \fIfiles\fR]
141 [\fB\-writerand\fR \fIfile\fR]
142 [\fB\-engine\fR \fIid\fR]
143 [\fB\-provider\fR \fIname\fR]
144 [\fB\-provider\-path\fR \fIpath\fR]
145 [\fB\-provparam\fR \fI[name:]key=value\fR]
146 [\fB\-propquery\fR \fIpropq\fR]
147 .SH DESCRIPTION
148 .IX Header "DESCRIPTION"
149 This command is a multi-purposes certificate handling command.
150 It can be used to print certificate information,
151 convert certificates to various forms, edit certificate trust settings,
152 generate certificates from scratch or from certification requests
153 and then self-signing them or signing them like a "micro CA".
154 .PP
155 Generated certificates bear X.509 version 3.
156 Unless specified otherwise,
157 key identifier extensions are included as described in \fBx509v3_config\fR\|(5).
158 .PP
159 Since there are a large number of options they will split up into
160 various sections.
161 .SH OPTIONS
162 .IX Header "OPTIONS"
163 .SS "Input, Output, and General Purpose Options"
164 .IX Subsection "Input, Output, and General Purpose Options"
165 .IP \fB\-help\fR 4
166 .IX Item "-help"
167 Print out a usage message.
168 .IP "\fB\-in\fR \fIfilename\fR|\fIuri\fR" 4
169 .IX Item "-in filename|uri"
170 This specifies the input to read a certificate from
171 or the input file for reading a certificate request if the \fB\-req\fR flag is used.
172 In both cases this defaults to standard input.
173 .Sp
174 This option cannot be combined with the \fB\-new\fR flag.
175 .IP "\fB\-passin\fR \fIarg\fR" 4
176 .IX Item "-passin arg"
177 The key and certificate file password source.
178 For more information about the format of \fIarg\fR
179 see \fBopenssl\-passphrase\-options\fR\|(1).
180 .IP \fB\-new\fR 4
181 .IX Item "-new"
182 Generate a certificate from scratch, not using an input certificate
183 or certificate request.
184 So this excludes the \fB\-in\fR and \fB\-req\fR options.
185 Instead, the \fB\-set_subject\fR option needs to be given.
186 The public key to include can be given with the \fB\-force_pubkey\fR option
187 and defaults to the key given with the \fB\-key\fR (or \fB\-signkey\fR) option,
188 which implies self-signature.
189 .IP \fB\-x509toreq\fR 4
190 .IX Item "-x509toreq"
191 Output a PKCS#10 certificate request (rather than a certificate).
192 The \fB\-key\fR (or \fB\-signkey\fR) option must be used to provide the private key for
193 self-signing; the corresponding public key is placed in the subjectPKInfo field.
194 .Sp
195 X.509 extensions included in a certificate input are not copied by default.
196 X.509 extensions to be added can be specified using the \fB\-extfile\fR option.
197 .IP \fB\-req\fR 4
198 .IX Item "-req"
199 By default a certificate is expected on input.
200 With this option a PKCS#10 certificate request is expected instead,
201 which must be correctly self-signed.
202 .Sp
203 X.509 extensions included in the request are not copied by default.
204 X.509 extensions to be added can be specified using the \fB\-extfile\fR option.
205 .IP "\fB\-copy_extensions\fR \fIarg\fR" 4
206 .IX Item "-copy_extensions arg"
207 Determines how to handle X.509 extensions
208 when converting from a certificate to a request using the \fB\-x509toreq\fR option
209 or converting from a request to a certificate using the \fB\-req\fR option.
210 If \fIarg\fR is \fBnone\fR or this option is not present then extensions are ignored.
211 If \fIarg\fR is \fBcopy\fR or \fBcopyall\fR then all extensions are copied,
212 except that subject identifier and authority key identifier extensions
213 are not taken over when producing a certificate request.
214 .Sp
215 The \fB\-ext\fR option can be used to further restrict which extensions to copy.
216 .IP "\fB\-inform\fR \fBDER\fR|\fBPEM\fR" 4
217 .IX Item "-inform DER|PEM"
218 The input file format to use; by default PEM is tried first.
219 See \fBopenssl\-format\-options\fR\|(1) for details.
220 .IP "\fB\-vfyopt\fR \fInm\fR:\fIv\fR" 4
221 .IX Item "-vfyopt nm:v"
222 Pass options to the signature algorithm during verify operations.
223 Names and values of these options are algorithm-specific.
224 .IP "\fB\-key\fR \fIfilename\fR|\fIuri\fR" 4
225 .IX Item "-key filename|uri"
226 This option provides the private key for signing a new certificate or
227 certificate request.
228 Unless \fB\-force_pubkey\fR is given, the corresponding public key is placed in
229 the new certificate or certificate request, resulting in a self-signature.
230 .Sp
231 This option cannot be used in conjunction with the \fB\-CA\fR option.
232 .Sp
233 It sets the issuer name to the subject name (i.e., makes it self-issued).
234 Unless the \fB\-preserve_dates\fR option is supplied,
235 it sets the validity start date to the current time
236 and the end date to a value determined by the \fB\-days\fR option.
237 Start date and end date can also be explicitly supplied with options
238 \&\fB\-not_before\fR and \fB\-not_after\fR.
239 .IP "\fB\-signkey\fR \fIfilename\fR|\fIuri\fR" 4
240 .IX Item "-signkey filename|uri"
241 This option is an alias of \fB\-key\fR.
242 .IP "\fB\-keyform\fR \fBDER\fR|\fBPEM\fR|\fBP12\fR|\fBENGINE\fR" 4
243 .IX Item "-keyform DER|PEM|P12|ENGINE"
244 The key input format; unspecified by default.
245 See \fBopenssl\-format\-options\fR\|(1) for details.
246 .IP "\fB\-out\fR \fIfilename\fR" 4
247 .IX Item "-out filename"
248 This specifies the output filename to write to or standard output by default.
249 .IP "\fB\-outform\fR \fBDER\fR|\fBPEM\fR" 4
250 .IX Item "-outform DER|PEM"
251 The output format; the default is \fBPEM\fR.
252 See \fBopenssl\-format\-options\fR\|(1) for details.
253 .IP \fB\-nocert\fR 4
254 .IX Item "-nocert"
255 Do not output a certificate (except for printing as requested by below options).
256 .IP \fB\-noout\fR 4
257 .IX Item "-noout"
258 This option prevents output except for printing as requested by below options.
259 .SS "Certificate Printing Options"
260 .IX Subsection "Certificate Printing Options"
261 Note: the \fB\-alias\fR and \fB\-purpose\fR options are also printing options
262 but are described in the "Trust Settings" section.
263 .IP \fB\-dateopt\fR 4
264 .IX Item "-dateopt"
265 Specify the date output format. Values are: rfc_822 and iso_8601.
266 Defaults to rfc_822.
267 .IP \fB\-text\fR 4
268 .IX Item "-text"
269 Prints out the certificate in text form. Full details are printed including the
270 public key, signature algorithms, issuer and subject names, serial number
271 any extensions present and any trust settings.
272 .IP "\fB\-certopt\fR \fIoption\fR" 4
273 .IX Item "-certopt option"
274 Customise the print format used with \fB\-text\fR. The \fIoption\fR argument
275 can be a single option or multiple options separated by commas.
276 The \fB\-certopt\fR switch may be also be used more than once to set multiple
277 options. See the "Text Printing Flags" section for more information.
278 .IP \fB\-fingerprint\fR 4
279 .IX Item "-fingerprint"
280 Calculates and prints the digest of the DER encoded version of the entire
281 certificate (see digest options).
282 This is commonly called a "fingerprint". Because of the nature of message
283 digests, the fingerprint of a certificate is unique to that certificate and
284 two certificates with the same fingerprint can be considered to be the same.
285 .IP \fB\-alias\fR 4
286 .IX Item "-alias"
287 Prints the certificate "alias" (nickname), if any.
288 .IP \fB\-serial\fR 4
289 .IX Item "-serial"
290 Prints the certificate serial number.
291 .IP \fB\-startdate\fR 4
292 .IX Item "-startdate"
293 Prints out the start date of the certificate, that is the notBefore date.
294 .IP \fB\-enddate\fR 4
295 .IX Item "-enddate"
296 Prints out the expiry date of the certificate, that is the notAfter date.
297 .IP \fB\-dates\fR 4
298 .IX Item "-dates"
299 Prints out the start and expiry dates of a certificate.
300 .IP \fB\-subject\fR 4
301 .IX Item "-subject"
302 Prints the subject name.
303 .IP \fB\-issuer\fR 4
304 .IX Item "-issuer"
305 Prints the issuer name.
306 .IP "\fB\-nameopt\fR \fIoption\fR" 4
307 .IX Item "-nameopt option"
308 This specifies how the subject or issuer names are displayed.
309 See \fBopenssl\-namedisplay\-options\fR\|(1) for details.
310 .IP \fB\-email\fR 4
311 .IX Item "-email"
312 Prints the email address(es) if any.
313 .IP \fB\-hash\fR 4
314 .IX Item "-hash"
315 Synonym for "\-subject_hash" for backward compatibility reasons.
316 .IP \fB\-subject_hash\fR 4
317 .IX Item "-subject_hash"
318 Prints the "hash" of the certificate subject name. This is used in OpenSSL to
319 form an index to allow certificates in a directory to be looked up by subject
320 name.
321 .IP \fB\-subject_hash_old\fR 4
322 .IX Item "-subject_hash_old"
323 Prints the "hash" of the certificate subject name using the older algorithm
324 as used by OpenSSL before version 1.0.0.
325 .IP \fB\-issuer_hash\fR 4
326 .IX Item "-issuer_hash"
327 Prints the "hash" of the certificate issuer name.
328 .IP \fB\-issuer_hash_old\fR 4
329 .IX Item "-issuer_hash_old"
330 Prints the "hash" of the certificate issuer name using the older algorithm
331 as used by OpenSSL before version 1.0.0.
332 .IP "\fB\-ext\fR \fIextensions\fR" 4
333 .IX Item "-ext extensions"
334 Prints out the certificate extensions in text form.
335 Can also be used to restrict which extensions to copy.
336 Extensions are specified
337 with a comma separated string, e.g., "subjectAltName, subjectKeyIdentifier".
338 See the \fBx509v3_config\fR\|(5) manual page for the extension names.
339 .IP \fB\-ocspid\fR 4
340 .IX Item "-ocspid"
341 Prints the OCSP hash values for the subject name and public key.
342 .IP \fB\-ocsp_uri\fR 4
343 .IX Item "-ocsp_uri"
344 Prints the OCSP responder address(es) if any.
345 .IP \fB\-purpose\fR 4
346 .IX Item "-purpose"
347 This option performs tests on the certificate extensions and outputs
348 the results. For a more complete description see
349 "Certificate Extensions" in \fBopenssl\-verification\-options\fR\|(1).
350 .IP \fB\-pubkey\fR 4
351 .IX Item "-pubkey"
352 Prints the certificate's SubjectPublicKeyInfo block in PEM format.
353 .IP \fB\-modulus\fR 4
354 .IX Item "-modulus"
355 This option prints out the value of the modulus of the public key
356 contained in the certificate.
357 .SS "Certificate Checking Options"
358 .IX Subsection "Certificate Checking Options"
359 .IP "\fB\-checkend\fR \fIarg\fR" 4
360 .IX Item "-checkend arg"
361 Checks if the certificate expires within the next \fIarg\fR seconds and exits
362 nonzero if yes it will expire or zero if not.
363 .IP "\fB\-checkhost\fR \fIhost\fR" 4
364 .IX Item "-checkhost host"
365 Check that the certificate matches the specified host.
366 .IP "\fB\-checkemail\fR \fIemail\fR" 4
367 .IX Item "-checkemail email"
368 Check that the certificate matches the specified email address.
369 .IP "\fB\-checkip\fR \fIipaddr\fR" 4
370 .IX Item "-checkip ipaddr"
371 Check that the certificate matches the specified IP address.
372 .SS "Certificate Output Options"
373 .IX Subsection "Certificate Output Options"
374 .IP "\fB\-set_serial\fR \fIn\fR" 4
375 .IX Item "-set_serial n"
376 Specifies the serial number to use.
377 This option can be used with the \fB\-key\fR, \fB\-signkey\fR, or \fB\-CA\fR options.
378 If used in conjunction with the \fB\-CA\fR option
379 the serial number file (as specified by the \fB\-CAserial\fR option) is not used.
380 .Sp
381 The serial number can be decimal or hex (if preceded by \f(CW\*(C`0x\*(C'\fR).
382 .IP \fB\-next_serial\fR 4
383 .IX Item "-next_serial"
384 Set the serial to be one more than the number in the certificate.
385 .IP "\fB\-not_before\fR \fIdate\fR" 4
386 .IX Item "-not_before date"
387 This allows the start date to be explicitly set. The format of the
388 date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure), or
389 YYYYMMDDHHMMSSZ (the same as an ASN1 GeneralizedTime structure). In
390 both formats, seconds SS and timezone Z must be present.
391 Alternatively, you can also use "today".
392 .Sp
393 Cannot be used together with the \fB\-preserve_dates\fR option.
394 .IP "\fB\-not_after\fR \fIdate\fR" 4
395 .IX Item "-not_after date"
396 This allows the expiry date to be explicitly set. The format of the
397 date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure), or
398 YYYYMMDDHHMMSSZ (the same as an ASN1 GeneralizedTime structure). In
399 both formats, seconds SS and timezone Z must be present.
400 Alternatively, you can also use "today".
401 .Sp
402 Cannot be used together with the \fB\-preserve_dates\fR option.
403 This overrides the option \fB\-days\fR.
404 .IP "\fB\-days\fR \fIarg\fR" 4
405 .IX Item "-days arg"
406 Specifies the number of days from today until a newly generated certificate expires.
407 The default is 30.
408 .Sp
409 Cannot be used together with the option \fB\-preserve_dates\fR.
410 If option \fB\-not_after\fR is set, the explicit expiry date takes precedence.
411 .IP \fB\-preserve_dates\fR 4
412 .IX Item "-preserve_dates"
413 When signing a certificate, preserve "notBefore" and "notAfter" dates of any
414 input certificate instead of adjusting them to current time and duration.
415 Cannot be used together with the options \fB\-days\fR, \fB\-not_before\fR and \fB\-not_after\fR.
416 .IP "\fB\-set_issuer\fR \fIarg\fR" 4
417 .IX Item "-set_issuer arg"
418 When a certificate is created set its issuer name to the given value.
419 .Sp
420 See \fB\-set_subject\fR on how the arg must be formatted.
421 .IP "\fB\-set_subject\fR \fIarg\fR" 4
422 .IX Item "-set_subject arg"
423 When a certificate is created set its subject name to the given value.
424 When the certificate is self-signed the issuer name is set to the same value,
425 unless the \fB\-set_issuer\fR option is given.
426 .Sp
427 The arg must be formatted as \f(CW\*(C`/type0=value0/type1=value1/type2=...\*(C'\fR.
428 Special characters may be escaped by \f(CW\*(C`\e\*(C'\fR (backslash), whitespace is retained.
429 Empty values are permitted, but the corresponding type will not be included
430 in the certificate.
431 Giving a single \f(CW\*(C`/\*(C'\fR will lead to an empty sequence of RDNs (a NULL-DN).
432 Multi-valued RDNs can be formed by placing a \f(CW\*(C`+\*(C'\fR character instead of a \f(CW\*(C`/\*(C'\fR
433 between the AttributeValueAssertions (AVAs) that specify the members of the set.
434 Example:
435 .Sp
436 \&\f(CW\*(C`/DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe\*(C'\fR
437 .Sp
438 This option can be used with the \fB\-new\fR and \fB\-force_pubkey\fR options to create
439 a new certificate without providing an input certificate or certificate request.
440 .IP "\fB\-subj\fR \fIarg\fR" 4
441 .IX Item "-subj arg"
442 This option is an alias of \fB\-set_subject\fR.
443 .IP "\fB\-force_pubkey\fR \fIfilename\fR" 4
444 .IX Item "-force_pubkey filename"
445 When a new certificate or certificate request is created
446 set its public key to the given key
447 instead of the key contained in the input
448 or given with the \fB\-key\fR (or \fB\-signkey\fR) option.
449 If the input contains no public key but a private key, its public part is used.
450 .Sp
451 This option can be used in conjunction with b<\-new> and \fB\-set_subject\fR
452 to directly generate a certificate containing any desired public key.
453 .Sp
454 This option is also useful for creating self-issued certificates that are not
455 self-signed, for instance when the key cannot be used for signing, such as DH.
456 .IP \fB\-clrext\fR 4
457 .IX Item "-clrext"
458 When transforming a certificate to a new certificate
459 by default all certificate extensions are retained.
460 .Sp
461 When transforming a certificate or certificate request,
462 the \fB\-clrext\fR option prevents taking over any extensions from the source.
463 In any case, when producing a certificate request,
464 neither subject identifier nor authority key identifier extensions are included.
465 .IP "\fB\-extfile\fR \fIfilename\fR" 4
466 .IX Item "-extfile filename"
467 Configuration file containing certificate and request X.509 extensions to add.
468 .IP "\fB\-extensions\fR \fIsection\fR" 4
469 .IX Item "-extensions section"
470 The section in the extfile to add X.509 extensions from.
471 If this option is not
472 specified then the extensions should either be contained in the unnamed
473 (default) section or the default section should contain a variable called
474 "extensions" which contains the section to use.
475 .Sp
476 See the \fBx509v3_config\fR\|(5) manual page for details of the
477 extension section format.
478 .Sp
479 Unless specified otherwise,
480 key identifier extensions are included as described in \fBx509v3_config\fR\|(5).
481 .IP "\fB\-sigopt\fR \fInm\fR:\fIv\fR" 4
482 .IX Item "-sigopt nm:v"
483 Pass options to the signature algorithm during sign operations.
484 This option may be given multiple times.
485 Names and values provided using this option are algorithm-specific.
486 .IP \fB\-badsig\fR 4
487 .IX Item "-badsig"
488 Corrupt the signature before writing it; this can be useful
489 for testing.
490 .IP \fB\-\fR\f(BIdigest\fR 4
491 .IX Item "-digest"
492 The digest to use.
493 This affects any signing or printing option that uses a message
494 digest, such as the \fB\-fingerprint\fR, \fB\-key\fR, and \fB\-CA\fR options.
495 Any digest supported by the \fBopenssl\-dgst\fR\|(1) command can be used.
496 If not specified then SHA1 is used with \fB\-fingerprint\fR or
497 the default digest for the signing algorithm is used, typically SHA256.
498 .SS "Micro-CA Options"
499 .IX Subsection "Micro-CA Options"
500 .IP "\fB\-CA\fR \fIfilename\fR|\fIuri\fR" 4
501 .IX Item "-CA filename|uri"
502 Specifies the "CA" certificate to be used for signing.
503 When present, this behaves like a "micro CA" as follows:
504 The subject name of the "CA" certificate is placed as issuer name in the new
505 certificate, which is then signed using the "CA" key given as detailed below.
506 .Sp
507 This option cannot be used in conjunction with \fB\-key\fR (or \fB\-signkey\fR).
508 This option is normally combined with the \fB\-req\fR option referencing a CSR.
509 Without the \fB\-req\fR option the input must be an existing certificate
510 unless the \fB\-new\fR option is given, which generates a certificate from scratch.
511 .IP "\fB\-CAform\fR \fBDER\fR|\fBPEM\fR|\fBP12\fR," 4
512 .IX Item "-CAform DER|PEM|P12,"
513 The format for the CA certificate; unspecified by default.
514 See \fBopenssl\-format\-options\fR\|(1) for details.
515 .IP "\fB\-CAkey\fR \fIfilename\fR|\fIuri\fR" 4
516 .IX Item "-CAkey filename|uri"
517 Sets the CA private key to sign a certificate with.
518 The private key must match the public key of the certificate given with \fB\-CA\fR.
519 If this option is not provided then the key must be present in the \fB\-CA\fR input.
520 .IP "\fB\-CAkeyform\fR \fBDER\fR|\fBPEM\fR|\fBP12\fR|\fBENGINE\fR" 4
521 .IX Item "-CAkeyform DER|PEM|P12|ENGINE"
522 The format for the CA key; unspecified by default.
523 See \fBopenssl\-format\-options\fR\|(1) for details.
524 .IP "\fB\-CAserial\fR \fIfilename\fR" 4
525 .IX Item "-CAserial filename"
526 Sets the CA serial number file to use.
527 .Sp
528 When creating a certificate with this option and with the \fB\-CA\fR option,
529 the certificate serial number is stored in the given file.
530 This file consists of one line containing
531 an even number of hex digits with the serial number used last time.
532 After reading this number, it is incremented and used, and the file is updated.
533 .Sp
534 The default filename consists of the CA certificate file base name with
535 \&\fI.srl\fR appended. For example if the CA certificate file is called
536 \&\fImycacert.pem\fR it expects to find a serial number file called
537 \&\fImycacert.srl\fR.
538 .Sp
539 If the \fB\-CA\fR option is specified and neither <\-CAserial> or <\-CAcreateserial>
540 is given and the default serial number file does not exist,
541 a random number is generated; this is the recommended practice.
542 .IP \fB\-CAcreateserial\fR 4
543 .IX Item "-CAcreateserial"
544 With this option and the \fB\-CA\fR option
545 the CA serial number file is created if it does not exist.
546 A random number is generated, used for the certificate,
547 and saved into the serial number file determined as described above.
548 .SS "Trust Settings"
549 .IX Subsection "Trust Settings"
550 A \fBtrusted certificate\fR is an ordinary certificate which has several
551 additional pieces of information attached to it such as the permitted
552 and prohibited uses of the certificate and possibly an "alias" (nickname).
553 .PP
554 Normally when a certificate is being verified at least one certificate
555 must be "trusted". By default a trusted certificate must be stored
556 locally and must be a root CA: any certificate chain ending in this CA
557 is then usable for any purpose.
558 .PP
559 Trust settings currently are only used with a root CA.
560 They allow a finer control over the purposes the root CA can be used for.
561 For example, a CA may be trusted for SSL client but not SSL server use.
562 .PP
563 See \fBopenssl\-verification\-options\fR\|(1) for more information
564 on the meaning of trust settings.
565 .PP
566 Future versions of OpenSSL will recognize trust settings on any
567 certificate: not just root CAs.
568 .IP \fB\-trustout\fR 4
569 .IX Item "-trustout"
570 Mark any certificate PEM output as <trusted> certificate rather than ordinary.
571 An ordinary or trusted certificate can be input but by default an ordinary
572 certificate is output and any trust settings are discarded.
573 With the \fB\-trustout\fR option a trusted certificate is output. A trusted
574 certificate is automatically output if any trust settings are modified.
575 .IP "\fB\-setalias\fR \fIarg\fR" 4
576 .IX Item "-setalias arg"
577 Sets the "alias" of the certificate. This will allow the certificate
578 to be referred to using a nickname for example "Steve's Certificate".
579 .IP \fB\-clrtrust\fR 4
580 .IX Item "-clrtrust"
581 Clears all the permitted or trusted uses of the certificate.
582 .IP "\fB\-addtrust\fR \fIarg\fR" 4
583 .IX Item "-addtrust arg"
584 Adds a trusted certificate use.
585 Any object name can be used here but currently only \fBclientAuth\fR,
586 \&\fBserverAuth\fR, \fBemailProtection\fR, and \fBanyExtendedKeyUsage\fR are defined.
587 As of OpenSSL 1.1.0, the last of these blocks all purposes when rejected or
588 enables all purposes when trusted.
589 Other OpenSSL applications may define additional uses.
590 .IP \fB\-clrreject\fR 4
591 .IX Item "-clrreject"
592 Clears all the prohibited or rejected uses of the certificate.
593 .IP "\fB\-addreject\fR \fIarg\fR" 4
594 .IX Item "-addreject arg"
595 Adds a prohibited trust anchor purpose.
596 It accepts the same values as the \fB\-addtrust\fR option.
597 .SS "Generic options"
598 .IX Subsection "Generic options"
599 .IP "\fB\-rand\fR \fIfiles\fR, \fB\-writerand\fR \fIfile\fR" 4
600 .IX Item "-rand files, -writerand file"
601 See "Random State Options" in \fBopenssl\fR\|(1) for details.
602 .IP "\fB\-engine\fR \fIid\fR" 4
603 .IX Item "-engine id"
604 See "Engine Options" in \fBopenssl\fR\|(1).
605 This option is deprecated.
606 .IP "\fB\-provider\fR \fIname\fR" 4
607 .IX Item "-provider name"
608 .PD 0
609 .IP "\fB\-provider\-path\fR \fIpath\fR" 4
610 .IX Item "-provider-path path"
611 .IP "\fB\-provparam\fR \fI[name:]key=value\fR" 4
612 .IX Item "-provparam [name:]key=value"
613 .IP "\fB\-propquery\fR \fIpropq\fR" 4
614 .IX Item "-propquery propq"
615 .PD
616 See "Provider Options" in \fBopenssl\fR\|(1), \fBprovider\fR\|(7), and \fBproperty\fR\|(7).
617 .SS "Text Printing Flags"
618 .IX Subsection "Text Printing Flags"
619 As well as customising the name printing format, it is also possible to
620 customise the actual fields printed using the \fBcertopt\fR option when
621 the \fBtext\fR option is present. The default behaviour is to print all fields.
622 .IP \fBcompatible\fR 4
623 .IX Item "compatible"
624 Use the old format. This is equivalent to specifying no printing options at all.
625 .IP \fBno_header\fR 4
626 .IX Item "no_header"
627 Don't print header information: that is the lines saying "Certificate"
628 and "Data".
629 .IP \fBno_version\fR 4
630 .IX Item "no_version"
631 Don't print out the version number.
632 .IP \fBno_serial\fR 4
633 .IX Item "no_serial"
634 Don't print out the serial number.
635 .IP \fBno_signame\fR 4
636 .IX Item "no_signame"
637 Don't print out the signature algorithm used.
638 .IP \fBno_validity\fR 4
639 .IX Item "no_validity"
640 Don't print the validity, that is the \fBnotBefore\fR and \fBnotAfter\fR fields.
641 .IP \fBno_subject\fR 4
642 .IX Item "no_subject"
643 Don't print out the subject name.
644 .IP \fBno_issuer\fR 4
645 .IX Item "no_issuer"
646 Don't print out the issuer name.
647 .IP \fBno_pubkey\fR 4
648 .IX Item "no_pubkey"
649 Don't print out the public key.
650 .IP \fBno_sigdump\fR 4
651 .IX Item "no_sigdump"
652 Don't give a hexadecimal dump of the certificate signature.
653 .IP \fBno_aux\fR 4
654 .IX Item "no_aux"
655 Don't print out certificate trust information.
656 .IP \fBno_extensions\fR 4
657 .IX Item "no_extensions"
658 Don't print out any X509V3 extensions.
659 .IP \fBext_default\fR 4
660 .IX Item "ext_default"
661 Retain default extension behaviour: attempt to print out unsupported
662 certificate extensions.
663 .IP \fBext_error\fR 4
664 .IX Item "ext_error"
665 Print an error message for unsupported certificate extensions.
666 .IP \fBext_parse\fR 4
667 .IX Item "ext_parse"
668 ASN1 parse unsupported extensions.
669 .IP \fBext_dump\fR 4
670 .IX Item "ext_dump"
671 Hex dump unsupported extensions.
672 .IP \fBca_default\fR 4
673 .IX Item "ca_default"
674 The value used by \fBopenssl\-ca\fR\|(1), equivalent to \fBno_issuer\fR, \fBno_pubkey\fR,
675 \&\fBno_header\fR, and \fBno_version\fR.
676 .SH EXAMPLES
677 .IX Header "EXAMPLES"
678 Note: in these examples the '\e' means the example should be all on one
679 line.
680 .PP
681 Print the contents of a certificate:
682 .PP
683 .Vb 1
684 \& openssl x509 \-in cert.pem \-noout \-text
685 .Ve
686 .PP
687 Print the "Subject Alternative Name" extension of a certificate:
688 .PP
689 .Vb 1
690 \& openssl x509 \-in cert.pem \-noout \-ext subjectAltName
691 .Ve
692 .PP
693 Print more extensions of a certificate:
694 .PP
695 .Vb 1
696 \& openssl x509 \-in cert.pem \-noout \-ext subjectAltName,nsCertType
697 .Ve
698 .PP
699 Print the certificate serial number:
700 .PP
701 .Vb 1
702 \& openssl x509 \-in cert.pem \-noout \-serial
703 .Ve
704 .PP
705 Print the certificate subject name:
706 .PP
707 .Vb 1
708 \& openssl x509 \-in cert.pem \-noout \-subject
709 .Ve
710 .PP
711 Print the certificate subject name in RFC2253 form:
712 .PP
713 .Vb 1
714 \& openssl x509 \-in cert.pem \-noout \-subject \-nameopt RFC2253
715 .Ve
716 .PP
717 Print the certificate subject name in oneline form on a terminal
718 supporting UTF8:
719 .PP
720 .Vb 1
721 \& openssl x509 \-in cert.pem \-noout \-subject \-nameopt oneline,\-esc_msb
722 .Ve
723 .PP
724 Print the certificate SHA1 fingerprint:
725 .PP
726 .Vb 1
727 \& openssl x509 \-sha1 \-in cert.pem \-noout \-fingerprint
728 .Ve
729 .PP
730 Convert a certificate from PEM to DER format:
731 .PP
732 .Vb 1
733 \& openssl x509 \-in cert.pem \-inform PEM \-out cert.der \-outform DER
734 .Ve
735 .PP
736 Convert a certificate to a certificate request:
737 .PP
738 .Vb 1
739 \& openssl x509 \-x509toreq \-in cert.pem \-out req.pem \-key key.pem
740 .Ve
741 .PP
742 Convert a certificate request into a self-signed certificate using
743 extensions for a CA:
744 .PP
745 .Vb 2
746 \& openssl x509 \-req \-in careq.pem \-extfile openssl.cnf \-extensions v3_ca \e
747 \& \-key key.pem \-out cacert.pem
748 .Ve
749 .PP
750 Sign a certificate request using the CA certificate above and add user
751 certificate extensions:
752 .PP
753 .Vb 2
754 \& openssl x509 \-req \-in req.pem \-extfile openssl.cnf \-extensions v3_usr \e
755 \& \-CA cacert.pem \-CAkey key.pem \-CAcreateserial
756 .Ve
757 .PP
758 Set a certificate to be trusted for SSL client use and change set its alias to
759 "Steve's Class 1 CA"
760 .PP
761 .Vb 2
762 \& openssl x509 \-in cert.pem \-addtrust clientAuth \e
763 \& \-setalias "Steve\*(Aqs Class 1 CA" \-out trust.pem
764 .Ve
765 .SH NOTES
766 .IX Header "NOTES"
767 The conversion to UTF8 format used with the name options assumes that
768 T61Strings use the ISO8859\-1 character set. This is wrong but Netscape
769 and MSIE do this as do many certificates. So although this is incorrect
770 it is more likely to print the majority of certificates correctly.
771 .PP
772 The \fB\-email\fR option searches the subject name and the subject alternative
773 name extension. Only unique email addresses will be printed out: it will
774 not print the same address more than once.
775 .SH BUGS
776 .IX Header "BUGS"
777 It is possible to produce invalid certificates or requests by specifying the
778 wrong private key, using unsuitable X.509 extensions,
779 or using inconsistent options in some cases: these should be checked.
780 .PP
781 There should be options to explicitly set such things as start and end
782 dates rather than an offset from the current time.
783 .SH "SEE ALSO"
784 .IX Header "SEE ALSO"
785 \&\fBopenssl\fR\|(1),
786 \&\fBopenssl\-req\fR\|(1),
787 \&\fBopenssl\-ca\fR\|(1),
788 \&\fBopenssl\-genrsa\fR\|(1),
789 \&\fBopenssl\-gendsa\fR\|(1),
790 \&\fBopenssl\-verify\fR\|(1),
791 \&\fBx509v3_config\fR\|(5)
792 .SH HISTORY
793 .IX Header "HISTORY"
794 The hash algorithm used in the \fB\-subject_hash\fR and \fB\-issuer_hash\fR options
795 before OpenSSL 1.0.0 was based on the deprecated MD5 algorithm and the encoding
796 of the distinguished name. In OpenSSL 1.0.0 and later it is based on a canonical
797 version of the DN using SHA1. This means that any directories using the old
798 form must have their links rebuilt using \fBopenssl\-rehash\fR\|(1) or similar.
799 .PP
800 The \fB\-signkey\fR option has been renamed to \fB\-key\fR in OpenSSL 3.0,
801 keeping the old name as an alias.
802 .PP
803 The \fB\-engine\fR option was deprecated in OpenSSL 3.0.
804 .PP
805 The \fB\-C\fR option was removed in OpenSSL 3.0.
806 .PP
807 Since OpenSSL 3.2, generated certificates bear X.509 version 3,
808 and key identifier extensions are included by default.
809 .SH COPYRIGHT
810 .IX Header "COPYRIGHT"
811 Copyright 2000\-2024 The OpenSSL Project Authors. All Rights Reserved.
812 .PP
813 Licensed under the Apache License 2.0 (the "License"). You may not use
814 this file except in compliance with the License. You can obtain a copy
815 in the file LICENSE in the source distribution or at
816 <https://www.openssl.org/source/license.html>.