Use a function to generate do-not-edit comment
[oweals/openssl.git] / doc / man1 / openssl-ts.pod.in
1 =pod
2 {- OpenSSL::safe::output_do_not_edit_headers(); -}
3
4 =head1 NAME
5
6 openssl-ts - Time Stamping Authority tool (client/server)
7
8 =head1 SYNOPSIS
9
10 B<openssl> B<ts>
11 B<-query>
12 [B<-config> I<configfile>]
13 [B<-data> I<file_to_hash>]
14 [B<-digest> I<digest_bytes>]
15 [B<-I<digest>>]
16 [B<-tspolicy> I<object_id>]
17 [B<-no_nonce>]
18 [B<-cert>]
19 [B<-in> I<request.tsq>]
20 [B<-out> I<request.tsq>]
21 [B<-text>]
22 {- $OpenSSL::safe::opt_r_synopsis -}
23
24 B<openssl> B<ts>
25 B<-reply>
26 [B<-config> I<configfile>]
27 [B<-section> I<tsa_section>]
28 [B<-queryfile> I<request.tsq>]
29 [B<-passin> I<password_src>]
30 [B<-signer> I<tsa_cert.pem>]
31 [B<-inkey> I<file_or_id>]
32 [B<-I<digest>>]
33 [B<-chain> I<certs_file.pem>]
34 [B<-tspolicy> I<object_id>]
35 [B<-in> I<response.tsr>]
36 [B<-token_in>]
37 [B<-out> I<response.tsr>]
38 [B<-token_out>]
39 [B<-text>]
40 [B<-engine> I<id>]
41
42 B<openssl> B<ts>
43 B<-verify>
44 [B<-data> I<file_to_hash>]
45 [B<-digest> I<digest_bytes>]
46 [B<-queryfile> I<request.tsq>]
47 [B<-in> I<response.tsr>]
48 [B<-token_in>]
49 [B<-CApath> I<trusted_cert_path>]
50 [B<-CAfile> I<trusted_certs.pem>]
51 [B<-CAstore> I<trusted_certs_uri>]
52 [B<-untrusted> I<cert_file.pem>]
53 [I<verify options>]
54
55 I<verify options:>
56 [B<-attime> I<timestamp>]
57 [B<-check_ss_sig>]
58 [B<-crl_check>]
59 [B<-crl_check_all>]
60 [B<-explicit_policy>]
61 [B<-extended_crl>]
62 [B<-ignore_critical>]
63 [B<-inhibit_any>]
64 [B<-inhibit_map>]
65 [B<-issuer_checks>]
66 [B<-no_alt_chains>]
67 [B<-no_check_time>]
68 [B<-partial_chain>]
69 [B<-policy> I<arg>]
70 [B<-policy_check>]
71 [B<-policy_print>]
72 [B<-purpose> I<purpose>]
73 [B<-suiteB_128>]
74 [B<-suiteB_128_only>]
75 [B<-suiteB_192>]
76 [B<-trusted_first>]
77 [B<-use_deltas>]
78 [B<-auth_level> I<num>]
79 [B<-verify_depth> I<num>]
80 [B<-verify_email> I<email>]
81 [B<-verify_hostname> I<hostname>]
82 [B<-verify_ip> I<ip>]
83 [B<-verify_name> I<name>]
84 [B<-x509_strict>]
85
86 =for openssl ifdef engine
87
88 =head1 DESCRIPTION
89
90 This command is a basic Time Stamping Authority (TSA) client and
91 server application as specified in RFC 3161 (Time-Stamp Protocol, TSP). A
92 TSA can be part of a PKI deployment and its role is to provide long
93 term proof of the existence of a certain datum before a particular
94 time. Here is a brief description of the protocol:
95
96 =over 4
97
98 =item 1.
99
100 The TSA client computes a one-way hash value for a data file and sends
101 the hash to the TSA.
102
103 =item 2.
104
105 The TSA attaches the current date and time to the received hash value,
106 signs them and sends the timestamp token back to the client. By
107 creating this token the TSA certifies the existence of the original
108 data file at the time of response generation.
109
110 =item 3.
111
112 The TSA client receives the timestamp token and verifies the
113 signature on it. It also checks if the token contains the same hash
114 value that it had sent to the TSA.
115
116 =back
117
118 There is one DER encoded protocol data unit defined for transporting a time
119 stamp request to the TSA and one for sending the timestamp response
120 back to the client. This command has three main functions:
121 creating a timestamp request based on a data file,
122 creating a timestamp response based on a request, verifying if a
123 response corresponds to a particular request or a data file.
124
125 There is no support for sending the requests/responses automatically
126 over HTTP or TCP yet as suggested in RFC 3161. The users must send the
127 requests either by ftp or e-mail.
128
129 =head1 OPTIONS
130
131 =head2 Timestamp Request generation
132
133 The B<-query> switch can be used for creating and printing a timestamp
134 request with the following options:
135
136 =over 4
137
138 =item B<-config> I<configfile>
139
140 The configuration file to use.
141 Optional; for a description of the default value,
142 see L<openssl(1)/COMMAND SUMMARY>.
143
144 =item B<-data> I<file_to_hash>
145
146 The data file for which the timestamp request needs to be
147 created. stdin is the default if neither the B<-data> nor the B<-digest>
148 parameter is specified. (Optional)
149
150 =item B<-digest> I<digest_bytes>
151
152 It is possible to specify the message imprint explicitly without the data
153 file. The imprint must be specified in a hexadecimal format, two characters
154 per byte, the bytes optionally separated by colons (e.g. 1A:F6:01:... or
155 1AF601...). The number of bytes must match the message digest algorithm
156 in use. (Optional)
157
158 =item B<-I<digest>>
159
160 The message digest to apply to the data file.
161 Any digest supported by the L<openssl-dgst(1)> command can be used.
162 The default is SHA-256. (Optional)
163
164 =item B<-tspolicy> I<object_id>
165
166 The policy that the client expects the TSA to use for creating the
167 timestamp token. Either the dotted OID notation or OID names defined
168 in the config file can be used. If no policy is requested the TSA will
169 use its own default policy. (Optional)
170
171 =item B<-no_nonce>
172
173 No nonce is specified in the request if this option is
174 given. Otherwise a 64 bit long pseudo-random none is
175 included in the request. It is recommended to use nonce to
176 protect against replay-attacks. (Optional)
177
178 =item B<-cert>
179
180 The TSA is expected to include its signing certificate in the
181 response. (Optional)
182
183 =item B<-in> I<request.tsq>
184
185 This option specifies a previously created timestamp request in DER
186 format that will be printed into the output file. Useful when you need
187 to examine the content of a request in human-readable
188 format. (Optional)
189
190 =item B<-out> I<request.tsq>
191
192 Name of the output file to which the request will be written. Default
193 is stdout. (Optional)
194
195 =item B<-text>
196
197 If this option is specified the output is human-readable text format
198 instead of DER. (Optional)
199
200 {- $OpenSSL::safe::opt_r_item -}
201
202 =back
203
204 =head2 Timestamp Response generation
205
206 A timestamp response (TimeStampResp) consists of a response status
207 and the timestamp token itself (ContentInfo), if the token generation was
208 successful. The B<-reply> command is for creating a timestamp
209 response or timestamp token based on a request and printing the
210 response/token in human-readable format. If B<-token_out> is not
211 specified the output is always a timestamp response (TimeStampResp),
212 otherwise it is a timestamp token (ContentInfo).
213
214 =over 4
215
216 =item B<-config> I<configfile>
217
218 The configuration file to use.
219 Optional; for a description of the default value,
220 see L<openssl(1)/COMMAND SUMMARY>.
221 See L</CONFIGURATION FILE OPTIONS> for configurable variables.
222
223 =item B<-section> I<tsa_section>
224
225 The name of the config file section containing the settings for the
226 response generation. If not specified the default TSA section is
227 used, see L</CONFIGURATION FILE OPTIONS> for details. (Optional)
228
229 =item B<-queryfile> I<request.tsq>
230
231 The name of the file containing a DER encoded timestamp request. (Optional)
232
233 =item B<-passin> I<password_src>
234
235 Specifies the password source for the private key of the TSA. See
236 description in L<openssl(1)>. (Optional)
237
238 =item B<-signer> I<tsa_cert.pem>
239
240 The signer certificate of the TSA in PEM format. The TSA signing
241 certificate must have exactly one extended key usage assigned to it:
242 timeStamping. The extended key usage must also be critical, otherwise
243 the certificate is going to be refused. Overrides the B<signer_cert>
244 variable of the config file. (Optional)
245
246 =item B<-inkey> I<file_or_id>
247
248 The signer private key of the TSA in PEM format. Overrides the
249 B<signer_key> config file option. (Optional)
250 If no engine is used, the argument is taken as a file; if an engine is
251 specified, the argument is given to the engine as a key identifier.
252
253 =item B<-I<digest>>
254
255 Signing digest to use. Overrides the B<signer_digest> config file
256 option. (Mandatory unless specified in the config file)
257
258 =item B<-chain> I<certs_file.pem>
259
260 The collection of certificates in PEM format that will all
261 be included in the response in addition to the signer certificate if
262 the B<-cert> option was used for the request. This file is supposed to
263 contain the certificate chain for the signer certificate from its
264 issuer upwards. The B<-reply> command does not build a certificate
265 chain automatically. (Optional)
266
267 =item B<-tspolicy> I<object_id>
268
269 The default policy to use for the response unless the client
270 explicitly requires a particular TSA policy. The OID can be specified
271 either in dotted notation or with its name. Overrides the
272 B<default_policy> config file option. (Optional)
273
274 =item B<-in> I<response.tsr>
275
276 Specifies a previously created timestamp response or timestamp token
277 (if B<-token_in> is also specified) in DER format that will be written
278 to the output file. This option does not require a request, it is
279 useful e.g. when you need to examine the content of a response or
280 token or you want to extract the timestamp token from a response. If
281 the input is a token and the output is a timestamp response a default
282 'granted' status info is added to the token. (Optional)
283
284 =item B<-token_in>
285
286 This flag can be used together with the B<-in> option and indicates
287 that the input is a DER encoded timestamp token (ContentInfo) instead
288 of a timestamp response (TimeStampResp). (Optional)
289
290 =item B<-out> I<response.tsr>
291
292 The response is written to this file. The format and content of the
293 file depends on other options (see B<-text>, B<-token_out>). The default is
294 stdout. (Optional)
295
296 =item B<-token_out>
297
298 The output is a timestamp token (ContentInfo) instead of timestamp
299 response (TimeStampResp). (Optional)
300
301 =item B<-text>
302
303 If this option is specified the output is human-readable text format
304 instead of DER. (Optional)
305
306 =item B<-engine> I<id>
307
308 Specifying an engine (by its unique I<id> string) will cause this command
309 to attempt to obtain a functional reference to the specified engine,
310 thus initialising it if needed. The engine will then be set as the default
311 for all available algorithms. Default is built-in. (Optional)
312
313 =back
314
315 =head2 Timestamp Response verification
316
317 The B<-verify> command is for verifying if a timestamp response or time
318 stamp token is valid and matches a particular timestamp request or
319 data file. The B<-verify> command does not use the configuration file.
320
321 =over 4
322
323 =item B<-data> I<file_to_hash>
324
325 The response or token must be verified against file_to_hash. The file
326 is hashed with the message digest algorithm specified in the token.
327 The B<-digest> and B<-queryfile> options must not be specified with this one.
328 (Optional)
329
330 =item B<-digest> I<digest_bytes>
331
332 The response or token must be verified against the message digest specified
333 with this option. The number of bytes must match the message digest algorithm
334 specified in the token. The B<-data> and B<-queryfile> options must not be
335 specified with this one. (Optional)
336
337 =item B<-queryfile> I<request.tsq>
338
339 The original timestamp request in DER format. The B<-data> and B<-digest>
340 options must not be specified with this one. (Optional)
341
342 =item B<-in> I<response.tsr>
343
344 The timestamp response that needs to be verified in DER format. (Mandatory)
345
346 =item B<-token_in>
347
348 This flag can be used together with the B<-in> option and indicates
349 that the input is a DER encoded timestamp token (ContentInfo) instead
350 of a timestamp response (TimeStampResp). (Optional)
351
352 =item B<-CAfile> I<file>, B<-CApath> I<dir>, B<-CAstore> I<uri>
353
354 See L<openssl(1)/Trusted Certificate Options> for more information.
355
356 At least one of B<-CApath>, B<-CAfile> or B<-CAstore> must be specified.
357
358 =item B<-untrusted> I<cert_file.pem>
359
360 Set of additional untrusted certificates in PEM format which may be
361 needed when building the certificate chain for the TSA's signing
362 certificate. This file must contain the TSA signing certificate and
363 all intermediate CA certificates unless the response includes them.
364 (Optional)
365
366 =item I<verify options>
367
368 The options B<-attime>, B<-check_ss_sig>, B<-crl_check>,
369 B<-crl_check_all>, B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>,
370 B<-inhibit_any>, B<-inhibit_map>, B<-issuer_checks>, B<-no_alt_chains>,
371 B<-no_check_time>, B<-partial_chain>, B<-policy>, B<-policy_check>,
372 B<-policy_print>, B<-purpose>, B<-suiteB_128>, B<-suiteB_128_only>,
373 B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>, B<-auth_level>,
374 B<-verify_depth>, B<-verify_email>, B<-verify_hostname>, B<-verify_ip>,
375 B<-verify_name>, and B<-x509_strict> can be used to control timestamp
376 verification.  See L<openssl-verify(1)>.
377
378 =back
379
380 =head1 CONFIGURATION FILE OPTIONS
381
382 The B<-query> and B<-reply> commands make use of a configuration file.
383 See L<config(5)>
384 for a general description of the syntax of the config file. The
385 B<-query> command uses only the symbolic OID names section
386 and it can work without it. However, the B<-reply> command needs the
387 config file for its operation.
388
389 When there is a command line switch equivalent of a variable the
390 switch always overrides the settings in the config file.
391
392 =over 4
393
394 =item B<tsa> section, B<default_tsa>
395
396 This is the main section and it specifies the name of another section
397 that contains all the options for the B<-reply> command. This default
398 section can be overridden with the B<-section> command line switch. (Optional)
399
400 =item B<oid_file>
401
402 This specifies a file containing additional B<OBJECT IDENTIFIERS>.
403 Each line of the file should consist of the numerical form of the
404 object identifier followed by white space then the short name followed
405 by white space and finally the long name. (Optional)
406
407 =item B<oid_section>
408
409 This specifies a section in the configuration file containing extra
410 object identifiers. Each line should consist of the short name of the
411 object identifier followed by B<=> and the numerical form. The short
412 and long names are the same when this option is used. (Optional)
413
414 =item B<RANDFILE>
415
416 At startup the specified file is loaded into the random number generator,
417 and at exit 256 bytes will be written to it. (Note: Using a RANDFILE is
418 not necessary anymore, see the L</HISTORY> section.
419
420 =item B<serial>
421
422 The name of the file containing the hexadecimal serial number of the
423 last timestamp response created. This number is incremented by 1 for
424 each response. If the file does not exist at the time of response
425 generation a new file is created with serial number 1. (Mandatory)
426
427 =item B<crypto_device>
428
429 Specifies the OpenSSL engine that will be set as the default for
430 all available algorithms. The default value is built-in, you can specify
431 any other engines supported by OpenSSL (e.g. use chil for the NCipher HSM).
432 (Optional)
433
434 =item B<signer_cert>
435
436 TSA signing certificate in PEM format. The same as the B<-signer>
437 command line option. (Optional)
438
439 =item B<certs>
440
441 A file containing a set of PEM encoded certificates that need to be
442 included in the response. The same as the B<-chain> command line
443 option. (Optional)
444
445 =item B<signer_key>
446
447 The private key of the TSA in PEM format. The same as the B<-inkey>
448 command line option. (Optional)
449
450 =item B<signer_digest>
451
452 Signing digest to use. The same as the
453 B<-I<digest>> command line option. (Mandatory unless specified on the command
454 line)
455
456 =item B<default_policy>
457
458 The default policy to use when the request does not mandate any
459 policy. The same as the B<-tspolicy> command line option. (Optional)
460
461 =item B<other_policies>
462
463 Comma separated list of policies that are also acceptable by the TSA
464 and used only if the request explicitly specifies one of them. (Optional)
465
466 =item B<digests>
467
468 The list of message digest algorithms that the TSA accepts. At least
469 one algorithm must be specified. (Mandatory)
470
471 =item B<accuracy>
472
473 The accuracy of the time source of the TSA in seconds, milliseconds
474 and microseconds. E.g. secs:1, millisecs:500, microsecs:100. If any of
475 the components is missing zero is assumed for that field. (Optional)
476
477 =item B<clock_precision_digits>
478
479 Specifies the maximum number of digits, which represent the fraction of
480 seconds, that  need to be included in the time field. The trailing zeros
481 must be removed from the time, so there might actually be fewer digits,
482 or no fraction of seconds at all. Supported only on UNIX platforms.
483 The maximum value is 6, default is 0.
484 (Optional)
485
486 =item B<ordering>
487
488 If this option is yes the responses generated by this TSA can always
489 be ordered, even if the time difference between two responses is less
490 than the sum of their accuracies. Default is no. (Optional)
491
492 =item B<tsa_name>
493
494 Set this option to yes if the subject name of the TSA must be included in
495 the TSA name field of the response. Default is no. (Optional)
496
497 =item B<ess_cert_id_chain>
498
499 The SignedData objects created by the TSA always contain the
500 certificate identifier of the signing certificate in a signed
501 attribute (see RFC 2634, Enhanced Security Services). If this option
502 is set to yes and either the B<certs> variable or the B<-chain> option
503 is specified then the certificate identifiers of the chain will also
504 be included in the SigningCertificate signed attribute. If this
505 variable is set to no, only the signing certificate identifier is
506 included. Default is no. (Optional)
507
508 =item B<ess_cert_id_alg>
509
510 This option specifies the hash function to be used to calculate the TSA's
511 public key certificate identifier. Default is sha256. (Optional)
512
513 =back
514
515 =head1 EXAMPLES
516
517 All the examples below presume that B<OPENSSL_CONF> is set to a proper
518 configuration file, e.g. the example configuration file
519 F<openssl/apps/openssl.cnf> will do.
520
521 =head2 Timestamp Request
522
523 To create a timestamp request for F<design1.txt> with SHA-256 digest,
524 without nonce and policy, and without requirement for a certificate
525 in the response:
526
527   openssl ts -query -data design1.txt -no_nonce \
528         -out design1.tsq
529
530 To create a similar timestamp request with specifying the message imprint
531 explicitly:
532
533   openssl ts -query -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
534          -no_nonce -out design1.tsq
535
536 To print the content of the previous request in human readable format:
537
538   openssl ts -query -in design1.tsq -text
539
540 To create a timestamp request which includes the SHA-512 digest
541 of F<design2.txt>, requests the signer certificate and nonce, and
542 specifies a policy id (assuming the tsa_policy1 name is defined in the
543 OID section of the config file):
544
545   openssl ts -query -data design2.txt -sha512 \
546         -tspolicy tsa_policy1 -cert -out design2.tsq
547
548 =head2 Timestamp Response
549
550 Before generating a response a signing certificate must be created for
551 the TSA that contains the B<timeStamping> critical extended key usage extension
552 without any other key usage extensions. You can add this line to the
553 user certificate section of the config file to generate a proper certificate;
554
555    extendedKeyUsage = critical,timeStamping
556
557 See L<openssl-req(1)>, L<openssl-ca(1)>, and L<openssl-x509(1)> for
558 instructions. The examples below assume that F<cacert.pem> contains the
559 certificate of the CA, F<tsacert.pem> is the signing certificate issued
560 by F<cacert.pem> and F<tsakey.pem> is the private key of the TSA.
561
562 To create a timestamp response for a request:
563
564   openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \
565         -signer tsacert.pem -out design1.tsr
566
567 If you want to use the settings in the config file you could just write:
568
569   openssl ts -reply -queryfile design1.tsq -out design1.tsr
570
571 To print a timestamp reply to stdout in human readable format:
572
573   openssl ts -reply -in design1.tsr -text
574
575 To create a timestamp token instead of timestamp response:
576
577   openssl ts -reply -queryfile design1.tsq -out design1_token.der -token_out
578
579 To print a timestamp token to stdout in human readable format:
580
581   openssl ts -reply -in design1_token.der -token_in -text -token_out
582
583 To extract the timestamp token from a response:
584
585   openssl ts -reply -in design1.tsr -out design1_token.der -token_out
586
587 To add 'granted' status info to a timestamp token thereby creating a
588 valid response:
589
590   openssl ts -reply -in design1_token.der -token_in -out design1.tsr
591
592 =head2 Timestamp Verification
593
594 To verify a timestamp reply against a request:
595
596   openssl ts -verify -queryfile design1.tsq -in design1.tsr \
597         -CAfile cacert.pem -untrusted tsacert.pem
598
599 To verify a timestamp reply that includes the certificate chain:
600
601   openssl ts -verify -queryfile design2.tsq -in design2.tsr \
602         -CAfile cacert.pem
603
604 To verify a timestamp token against the original data file:
605   openssl ts -verify -data design2.txt -in design2.tsr \
606         -CAfile cacert.pem
607
608 To verify a timestamp token against a message imprint:
609   openssl ts -verify -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
610          -in design2.tsr -CAfile cacert.pem
611
612 You could also look at the 'test' directory for more examples.
613
614 =head1 BUGS
615
616 =for openssl foreign manuals: procmail(1), perl(1)
617
618 =over 2
619
620 =item *
621
622 No support for timestamps over SMTP, though it is quite easy
623 to implement an automatic e-mail based TSA with L<procmail(1)>
624 and L<perl(1)>. HTTP server support is provided in the form of
625 a separate apache module. HTTP client support is provided by
626 L<tsget(1)>. Pure TCP/IP protocol is not supported.
627
628 =item *
629
630 The file containing the last serial number of the TSA is not
631 locked when being read or written. This is a problem if more than one
632 instance of L<openssl(1)> is trying to create a timestamp
633 response at the same time. This is not an issue when using the apache
634 server module, it does proper locking.
635
636 =item *
637
638 Look for the FIXME word in the source files.
639
640 =item *
641
642 The source code should really be reviewed by somebody else, too.
643
644 =item *
645
646 More testing is needed, I have done only some basic tests (see
647 test/testtsa).
648
649 =back
650
651 =head1 HISTORY
652
653 OpenSSL 1.1.1 introduced a new random generator (CSPRNG) with an improved
654 seeding mechanism. The new seeding mechanism makes it unnecessary to
655 define a RANDFILE for saving and restoring randomness. This option is
656 retained mainly for compatibility reasons.
657
658 =head1 SEE ALSO
659
660 L<openssl(1)>,
661 L<openssl-tsget(1)>,
662 L<openssl-req(1)>,
663 L<openssl-x509(1)>,
664 L<openssl-ca(1)>,
665 L<openssl-genrsa(1)>,
666 L<config(5)>,
667 L<ossl_store-file(7)>
668
669 =head1 COPYRIGHT
670
671 Copyright 2006-2019 The OpenSSL Project Authors. All Rights Reserved.
672
673 Licensed under the Apache License 2.0 (the "License").  You may not use
674 this file except in compliance with the License.  You can obtain a copy
675 in the file LICENSE in the source distribution or at
676 L<https://www.openssl.org/source/license.html>.
677
678 =cut