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