-inkey can be an identifier, not just a file
[openssl.git] / doc / man1 / ts.pod
1 =pod
2
3 =head1 NAME
4
5 ts - Time Stamping Authority tool (client/server)
6
7 =head1 SYNOPSIS
8
9 B<openssl> B<ts>
10 B<-query>
11 [B<-rand> file:file...]
12 [B<-config> configfile]
13 [B<-data> file_to_hash]
14 [B<-digest> digest_bytes]
15 [B<-[digest]>]
16 [B<-tspolicy> object_id]
17 [B<-no_nonce>]
18 [B<-cert>]
19 [B<-in> request.tsq]
20 [B<-out> request.tsq]
21 [B<-text>]
22
23 B<openssl> B<ts>
24 B<-reply>
25 [B<-config> configfile]
26 [B<-section> tsa_section]
27 [B<-queryfile> request.tsq]
28 [B<-passin> password_src]
29 [B<-signer> tsa_cert.pem]
30 [B<-inkey> file_or_id]
31 [B<-sha1|-sha224|-sha256|-sha384|-sha512>]
32 [B<-chain> certs_file.pem]
33 [B<-tspolicy> object_id]
34 [B<-in> response.tsr]
35 [B<-token_in>]
36 [B<-out> response.tsr]
37 [B<-token_out>]
38 [B<-text>]
39 [B<-engine> id]
40
41 B<openssl> B<ts>
42 B<-verify>
43 [B<-data> file_to_hash]
44 [B<-digest> digest_bytes]
45 [B<-queryfile> request.tsq]
46 [B<-in> response.tsr]
47 [B<-token_in>]
48 [B<-CApath> trusted_cert_path]
49 [B<-CAfile> trusted_certs.pem]
50 [B<-untrusted> cert_file.pem]
51 [I<verify options>]
52
53 I<verify options:>
54 [-attime timestamp]
55 [-check_ss_sig]
56 [-crl_check]
57 [-crl_check_all]
58 [-explicit_policy]
59 [-extended_crl]
60 [-ignore_critical]
61 [-inhibit_any]
62 [-inhibit_map]
63 [-issuer_checks]
64 [-no_alt_chains]
65 [-no_check_time]
66 [-partial_chain]
67 [-policy arg]
68 [-policy_check]
69 [-policy_print]
70 [-purpose purpose]
71 [-suiteB_128]
72 [-suiteB_128_only]
73 [-suiteB_192]
74 [-trusted_first]
75 [-use_deltas]
76 [-auth_level num]
77 [-verify_depth num]
78 [-verify_email email]
79 [-verify_hostname hostname]
80 [-verify_ip ip]
81 [-verify_name name]
82 [-x509_strict]
83
84 =head1 DESCRIPTION
85
86 The B<ts> command is a basic Time Stamping Authority (TSA) client and server
87 application as specified in RFC 3161 (Time-Stamp Protocol, TSP). A
88 TSA can be part of a PKI deployment and its role is to provide long
89 term proof of the existence of a certain datum before a particular
90 time. Here is a brief description of the protocol:
91
92 =over 4
93
94 =item 1.
95
96 The TSA client computes a one-way hash value for a data file and sends
97 the hash to the TSA.
98
99 =item 2.
100
101 The TSA attaches the current date and time to the received hash value,
102 signs them and sends the time stamp token back to the client. By
103 creating this token the TSA certifies the existence of the original
104 data file at the time of response generation.
105
106 =item 3.
107
108 The TSA client receives the time stamp token and verifies the
109 signature on it. It also checks if the token contains the same hash
110 value that it had sent to the TSA.
111
112 =back
113
114 There is one DER encoded protocol data unit defined for transporting a time
115 stamp request to the TSA and one for sending the time stamp response
116 back to the client. The B<ts> command has three main functions:
117 creating a time stamp request based on a data file,
118 creating a time stamp response based on a request, verifying if a
119 response corresponds to a particular request or a data file.
120
121 There is no support for sending the requests/responses automatically
122 over HTTP or TCP yet as suggested in RFC 3161. The users must send the
123 requests either by ftp or e-mail.
124
125 =head1 OPTIONS
126
127 =head2 Time Stamp Request generation
128
129 The B<-query> switch can be used for creating and printing a time stamp
130 request with the following options:
131
132 =over 4
133
134 =item B<-rand> file:file...
135
136 The files containing random data for seeding the random number
137 generator. Multiple files can be specified, the separator is B<;> for
138 MS-Windows, B<,> for VMS and B<:> for all other platforms. (Optional)
139
140 =item B<-config> configfile
141
142 The configuration file to use.
143 Optional; for a description of the default value,
144 see L<openssl(1)/COMMAND SUMMARY>.
145
146 =item B<-data> file_to_hash
147
148 The data file for which the time stamp request needs to be
149 created. stdin is the default if neither the B<-data> nor the B<-digest>
150 parameter is specified. (Optional)
151
152 =item B<-digest> digest_bytes
153
154 It is possible to specify the message imprint explicitly without the data
155 file. The imprint must be specified in a hexadecimal format, two characters
156 per byte, the bytes optionally separated by colons (e.g. 1A:F6:01:... or
157 1AF601...). The number of bytes must match the message digest algorithm
158 in use. (Optional)
159
160 =item B<-[digest]>
161
162 The message digest to apply to the data file.
163 Any digest supported by the OpenSSL B<dgst> command can be used.
164 The default is SHA-1. (Optional)
165
166 =item B<-tspolicy> object_id
167
168 The policy that the client expects the TSA to use for creating the
169 time stamp token. Either the dotted OID notation or OID names defined
170 in the config file can be used. If no policy is requested the TSA will
171 use its own default policy. (Optional)
172
173 =item B<-no_nonce>
174
175 No nonce is specified in the request if this option is
176 given. Otherwise a 64 bit long pseudo-random none is
177 included in the request. It is recommended to use nonce to
178 protect against replay-attacks. (Optional)
179
180 =item B<-cert>
181
182 The TSA is expected to include its signing certificate in the
183 response. (Optional)
184
185 =item B<-in> request.tsq
186
187 This option specifies a previously created time stamp request in DER
188 format that will be printed into the output file. Useful when you need
189 to examine the content of a request in human-readable
190 format. (Optional)
191
192 =item B<-out> request.tsq
193
194 Name of the output file to which the request will be written. Default
195 is stdout. (Optional)
196
197 =item B<-text>
198
199 If this option is specified the output is human-readable text format
200 instead of DER. (Optional)
201
202 =back
203
204 =head2 Time Stamp Response generation
205
206 A time stamp response (TimeStampResp) consists of a response status
207 and the time stamp token itself (ContentInfo), if the token generation was
208 successful. The B<-reply> command is for creating a time stamp
209 response or time stamp 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 time stamp response (TimeStampResp),
212 otherwise it is a time stamp token (ContentInfo).
213
214 =over 4
215
216 =item B<-config> 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 B<CONFIGURATION FILE OPTIONS> for configurable variables.
222
223 =item B<-section> 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 B<CONFIGURATION FILE OPTIONS> for details. (Optional)
228
229 =item B<-queryfile> request.tsq
230
231 The name of the file containing a DER encoded time stamp request. (Optional)
232
233 =item B<-passin> password_src
234
235 Specifies the password source for the private key of the TSA. See
236 B<PASS PHRASE ARGUMENTS> in L<openssl(1)>. (Optional)
237
238 =item B<-signer> 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> 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<-sha1|-sha224|-sha256|-sha384|-sha512>
254
255 Signing digest to use. Overrides the B<signer_digest> config file
256 option. (Optional)
257
258 =item B<-chain> 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> 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> response.tsr
275
276 Specifies a previously created time stamp response or time stamp 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 time stamp token from a response. If
281 the input is a token and the output is a time stamp 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 time stamp token (ContentInfo) instead
288 of a time stamp response (TimeStampResp). (Optional)
289
290 =item B<-out> 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 time stamp token (ContentInfo) instead of time stamp
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> id
307
308 Specifying an engine (by its unique B<id> string) will cause B<ts>
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 builtin. (Optional)
312
313 =back
314
315 =head2 Time Stamp Response verification
316
317 The B<-verify> command is for verifying if a time stamp response or time
318 stamp token is valid and matches a particular time stamp request or
319 data file. The B<-verify> command does not use the configuration file.
320
321 =over 4
322
323 =item B<-data> 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> 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> request.tsq
338
339 The original time stamp 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> response.tsr
343
344 The time stamp 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 time stamp token (ContentInfo) instead
350 of a time stamp response (TimeStampResp). (Optional)
351
352 =item B<-CApath> trusted_cert_path
353
354 The name of the directory containing the trusted CA certificates of the
355 client. See the similar option of L<verify(1)> for additional
356 details. Either this option or B<-CAfile> must be specified. (Optional)
357
358
359 =item B<-CAfile> trusted_certs.pem
360
361 The name of the file containing a set of trusted self-signed CA
362 certificates in PEM format. See the similar option of
363 L<verify(1)> for additional details. Either this option
364 or B<-CApath> must be specified.
365 (Optional)
366
367 =item B<-untrusted> cert_file.pem
368
369 Set of additional untrusted certificates in PEM format which may be
370 needed when building the certificate chain for the TSA's signing
371 certificate. This file must contain the TSA signing certificate and
372 all intermediate CA certificates unless the response includes them.
373 (Optional)
374
375 =item I<verify options>
376
377 The options B<-attime timestamp>, B<-check_ss_sig>, B<-crl_check>,
378 B<-crl_check_all>, B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>,
379 B<-inhibit_any>, B<-inhibit_map>, B<-issuer_checks>, B<-no_alt_chains>,
380 B<-no_check_time>, B<-partial_chain>, B<-policy>, B<-policy_check>,
381 B<-policy_print>, B<-purpose>, B<-suiteB_128>, B<-suiteB_128_only>,
382 B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>, B<-auth_level>,
383 B<-verify_depth>, B<-verify_email>, B<-verify_hostname>, B<-verify_ip>,
384 B<-verify_name>, and B<-x509_strict> can be used to control timestamp
385 verification.  See L<verify(1)>.
386
387 =back
388
389 =head1 CONFIGURATION FILE OPTIONS
390
391 The B<-query> and B<-reply> commands make use of a configuration file.
392 See L<config(5)>
393 for a general description of the syntax of the config file. The
394 B<-query> command uses only the symbolic OID names section
395 and it can work without it. However, the B<-reply> command needs the
396 config file for its operation.
397
398 When there is a command line switch equivalent of a variable the
399 switch always overrides the settings in the config file.
400
401 =over 4
402
403 =item B<tsa> section, B<default_tsa>
404
405 This is the main section and it specifies the name of another section
406 that contains all the options for the B<-reply> command. This default
407 section can be overridden with the B<-section> command line switch. (Optional)
408
409 =item B<oid_file>
410
411 See L<ca(1)> for description. (Optional)
412
413 =item B<oid_section>
414
415 See L<ca(1)> for description. (Optional)
416
417 =item B<RANDFILE>
418
419 See L<ca(1)> for description. (Optional)
420
421 =item B<serial>
422
423 The name of the file containing the hexadecimal serial number of the
424 last time stamp response created. This number is incremented by 1 for
425 each response. If the file does not exist at the time of response
426 generation a new file is created with serial number 1. (Mandatory)
427
428 =item B<crypto_device>
429
430 Specifies the OpenSSL engine that will be set as the default for
431 all available algorithms. The default value is builtin, you can specify
432 any other engines supported by OpenSSL (e.g. use chil for the NCipher HSM).
433 (Optional)
434
435 =item B<signer_cert>
436
437 TSA signing certificate in PEM format. The same as the B<-signer>
438 command line option. (Optional)
439
440 =item B<certs>
441
442 A file containing a set of PEM encoded certificates that need to be
443 included in the response. The same as the B<-chain> command line
444 option. (Optional)
445
446 =item B<signer_key>
447
448 The private key of the TSA in PEM format. The same as the B<-inkey>
449 command line option. (Optional)
450
451 =item B<signer_digest>
452
453 Signing digest to use. The same as the
454 B<-sha1|-sha224|-sha256|-sha384|-sha512> command line option. (Optional)
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 zeroes
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 sha1. (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 openssl/apps/openssl.cnf will do.
520
521 =head2 Time Stamp Request
522
523 To create a time stamp request for design1.txt with SHA-1
524 without nonce and policy and no certificate is required in the response:
525
526   openssl ts -query -data design1.txt -no_nonce \
527         -out design1.tsq
528
529 To create a similar time stamp request with specifying the message imprint
530 explicitly:
531
532   openssl ts -query -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
533          -no_nonce -out design1.tsq
534
535 To print the content of the previous request in human readable format:
536
537   openssl ts -query -in design1.tsq -text
538
539 To create a time stamp request which includes the MD-5 digest
540 of design2.txt, requests the signer certificate and nonce,
541 specifies a policy id (assuming the tsa_policy1 name is defined in the
542 OID section of the config file):
543
544   openssl ts -query -data design2.txt -md5 \
545         -tspolicy tsa_policy1 -cert -out design2.tsq
546
547 =head2 Time Stamp Response
548
549 Before generating a response a signing certificate must be created for
550 the TSA that contains the B<timeStamping> critical extended key usage extension
551 without any other key usage extensions. You can add the
552 'extendedKeyUsage = critical,timeStamping' line to the user certificate section
553 of the config file to generate a proper certificate. See L<req(1)>,
554 L<ca(1)>, L<x509(1)> for instructions. The examples
555 below assume that cacert.pem contains the certificate of the CA,
556 tsacert.pem is the signing certificate issued by cacert.pem and
557 tsakey.pem is the private key of the TSA.
558
559 To create a time stamp response for a request:
560
561   openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \
562         -signer tsacert.pem -out design1.tsr
563
564 If you want to use the settings in the config file you could just write:
565
566   openssl ts -reply -queryfile design1.tsq -out design1.tsr
567
568 To print a time stamp reply to stdout in human readable format:
569
570   openssl ts -reply -in design1.tsr -text
571
572 To create a time stamp token instead of time stamp response:
573
574   openssl ts -reply -queryfile design1.tsq -out design1_token.der -token_out
575
576 To print a time stamp token to stdout in human readable format:
577
578   openssl ts -reply -in design1_token.der -token_in -text -token_out
579
580 To extract the time stamp token from a response:
581
582   openssl ts -reply -in design1.tsr -out design1_token.der -token_out
583
584 To add 'granted' status info to a time stamp token thereby creating a
585 valid response:
586
587   openssl ts -reply -in design1_token.der -token_in -out design1.tsr
588
589 =head2 Time Stamp Verification
590
591 To verify a time stamp reply against a request:
592
593   openssl ts -verify -queryfile design1.tsq -in design1.tsr \
594         -CAfile cacert.pem -untrusted tsacert.pem
595
596 To verify a time stamp reply that includes the certificate chain:
597
598   openssl ts -verify -queryfile design2.tsq -in design2.tsr \
599         -CAfile cacert.pem
600
601 To verify a time stamp token against the original data file:
602   openssl ts -verify -data design2.txt -in design2.tsr \
603         -CAfile cacert.pem
604
605 To verify a time stamp token against a message imprint:
606   openssl ts -verify -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
607          -in design2.tsr -CAfile cacert.pem
608
609 You could also look at the 'test' directory for more examples.
610
611 =head1 BUGS
612
613 =for comment foreign manuals: procmail(1), perl(1)
614
615 =over 2
616
617 =item *
618
619 No support for time stamps over SMTP, though it is quite easy
620 to implement an automatic e-mail based TSA with L<procmail(1)>
621 and L<perl(1)>. HTTP server support is provided in the form of
622 a separate apache module. HTTP client support is provided by
623 L<tsget(1)>. Pure TCP/IP protocol is not supported.
624
625 =item *
626
627 The file containing the last serial number of the TSA is not
628 locked when being read or written. This is a problem if more than one
629 instance of L<openssl(1)> is trying to create a time stamp
630 response at the same time. This is not an issue when using the apache
631 server module, it does proper locking.
632
633 =item *
634
635 Look for the FIXME word in the source files.
636
637 =item *
638
639 The source code should really be reviewed by somebody else, too.
640
641 =item *
642
643 More testing is needed, I have done only some basic tests (see
644 test/testtsa).
645
646 =back
647
648 =head1 SEE ALSO
649
650 L<tsget(1)>, L<openssl(1)>, L<req(1)>,
651 L<x509(1)>, L<ca(1)>, L<genrsa(1)>,
652 L<config(5)>
653
654 =head1 COPYRIGHT
655
656 Copyright 2006-2017 The OpenSSL Project Authors. All Rights Reserved.
657
658 Licensed under the OpenSSL license (the "License").  You may not use
659 this file except in compliance with the License.  You can obtain a copy
660 in the file LICENSE in the source distribution or at
661 L<https://www.openssl.org/source/license.html>.
662
663 =cut