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