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