Debian Codegraph @

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