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