6 ts - Time Stamping Authority tool (client/server)
14 [B<-config> configfile]
15 [B<-data> file_to_hash]
16 [B<-digest> digest_bytes]
18 [B<-tspolicy> object_id]
27 [B<-config> configfile]
28 [B<-section> tsa_section]
29 [B<-queryfile> request.tsq]
30 [B<-passin> password_src]
31 [B<-signer> tsa_cert.pem]
32 [B<-inkey> file_or_id]
34 [B<-chain> certs_file.pem]
35 [B<-tspolicy> object_id]
38 [B<-out> response.tsr]
45 [B<-data> file_to_hash]
46 [B<-digest> digest_bytes]
47 [B<-queryfile> request.tsq]
50 [B<-CApath> trusted_cert_path]
51 [B<-CAfile> trusted_certs.pem]
52 [B<-untrusted> cert_file.pem]
81 [-verify_hostname hostname]
88 The B<ts> command is a basic Time Stamping Authority (TSA) client and server
89 application as specified in RFC 3161 (Time-Stamp Protocol, TSP). A
90 TSA can be part of a PKI deployment and its role is to provide long
91 term proof of the existence of a certain datum before a particular
92 time. Here is a brief description of the protocol:
98 The TSA client computes a one-way hash value for a data file and sends
103 The TSA attaches the current date and time to the received hash value,
104 signs them and sends the time stamp token back to the client. By
105 creating this token the TSA certifies the existence of the original
106 data file at the time of response generation.
110 The TSA client receives the time stamp token and verifies the
111 signature on it. It also checks if the token contains the same hash
112 value that it had sent to the TSA.
116 There is one DER encoded protocol data unit defined for transporting a time
117 stamp request to the TSA and one for sending the time stamp response
118 back to the client. The B<ts> command has three main functions:
119 creating a time stamp request based on a data file,
120 creating a time stamp response based on a request, verifying if a
121 response corresponds to a particular request or a data file.
123 There is no support for sending the requests/responses automatically
124 over HTTP or TCP yet as suggested in RFC 3161. The users must send the
125 requests either by ftp or e-mail.
129 =head2 Time Stamp Request generation
131 The B<-query> switch can be used for creating and printing a time stamp
132 request with the following options:
136 =item B<-rand file...>
138 A file or files containing random data used to seed the random number
140 Multiple files can be specified separated by an OS-dependent character.
141 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
144 =item [B<-writerand file>]
146 Writes random data to the specified I<file> upon exit.
147 This can be used with a subsequent B<-rand> flag.
149 =item B<-config> configfile
151 The configuration file to use.
152 Optional; for a description of the default value,
153 see L<openssl(1)/COMMAND SUMMARY>.
155 =item B<-data> file_to_hash
157 The data file for which the time stamp request needs to be
158 created. stdin is the default if neither the B<-data> nor the B<-digest>
159 parameter is specified. (Optional)
161 =item B<-digest> digest_bytes
163 It is possible to specify the message imprint explicitly without the data
164 file. The imprint must be specified in a hexadecimal format, two characters
165 per byte, the bytes optionally separated by colons (e.g. 1A:F6:01:... or
166 1AF601...). The number of bytes must match the message digest algorithm
171 The message digest to apply to the data file.
172 Any digest supported by the OpenSSL B<dgst> command can be used.
173 The default is SHA-1. (Optional)
175 =item B<-tspolicy> object_id
177 The policy that the client expects the TSA to use for creating the
178 time stamp token. Either the dotted OID notation or OID names defined
179 in the config file can be used. If no policy is requested the TSA will
180 use its own default policy. (Optional)
184 No nonce is specified in the request if this option is
185 given. Otherwise a 64 bit long pseudo-random none is
186 included in the request. It is recommended to use nonce to
187 protect against replay-attacks. (Optional)
191 The TSA is expected to include its signing certificate in the
194 =item B<-in> request.tsq
196 This option specifies a previously created time stamp request in DER
197 format that will be printed into the output file. Useful when you need
198 to examine the content of a request in human-readable
201 =item B<-out> request.tsq
203 Name of the output file to which the request will be written. Default
204 is stdout. (Optional)
208 If this option is specified the output is human-readable text format
209 instead of DER. (Optional)
213 =head2 Time Stamp Response generation
215 A time stamp response (TimeStampResp) consists of a response status
216 and the time stamp token itself (ContentInfo), if the token generation was
217 successful. The B<-reply> command is for creating a time stamp
218 response or time stamp token based on a request and printing the
219 response/token in human-readable format. If B<-token_out> is not
220 specified the output is always a time stamp response (TimeStampResp),
221 otherwise it is a time stamp token (ContentInfo).
225 =item B<-config> configfile
227 The configuration file to use.
228 Optional; for a description of the default value,
229 see L<openssl(1)/COMMAND SUMMARY>.
230 See B<CONFIGURATION FILE OPTIONS> for configurable variables.
232 =item B<-section> tsa_section
234 The name of the config file section containing the settings for the
235 response generation. If not specified the default TSA section is
236 used, see B<CONFIGURATION FILE OPTIONS> for details. (Optional)
238 =item B<-queryfile> request.tsq
240 The name of the file containing a DER encoded time stamp request. (Optional)
242 =item B<-passin> password_src
244 Specifies the password source for the private key of the TSA. See
245 B<PASS PHRASE ARGUMENTS> in L<openssl(1)>. (Optional)
247 =item B<-signer> tsa_cert.pem
249 The signer certificate of the TSA in PEM format. The TSA signing
250 certificate must have exactly one extended key usage assigned to it:
251 timeStamping. The extended key usage must also be critical, otherwise
252 the certificate is going to be refused. Overrides the B<signer_cert>
253 variable of the config file. (Optional)
255 =item B<-inkey> file_or_id
257 The signer private key of the TSA in PEM format. Overrides the
258 B<signer_key> config file option. (Optional)
259 If no engine is used, the argument is taken as a file; if an engine is
260 specified, the argument is given to the engine as a key identifier.
264 Signing digest to use. Overrides the B<signer_digest> config file
267 =item B<-chain> certs_file.pem
269 The collection of certificates in PEM format that will all
270 be included in the response in addition to the signer certificate if
271 the B<-cert> option was used for the request. This file is supposed to
272 contain the certificate chain for the signer certificate from its
273 issuer upwards. The B<-reply> command does not build a certificate
274 chain automatically. (Optional)
276 =item B<-tspolicy> object_id
278 The default policy to use for the response unless the client
279 explicitly requires a particular TSA policy. The OID can be specified
280 either in dotted notation or with its name. Overrides the
281 B<default_policy> config file option. (Optional)
283 =item B<-in> response.tsr
285 Specifies a previously created time stamp response or time stamp token
286 (if B<-token_in> is also specified) in DER format that will be written
287 to the output file. This option does not require a request, it is
288 useful e.g. when you need to examine the content of a response or
289 token or you want to extract the time stamp token from a response. If
290 the input is a token and the output is a time stamp response a default
291 'granted' status info is added to the token. (Optional)
295 This flag can be used together with the B<-in> option and indicates
296 that the input is a DER encoded time stamp token (ContentInfo) instead
297 of a time stamp response (TimeStampResp). (Optional)
299 =item B<-out> response.tsr
301 The response is written to this file. The format and content of the
302 file depends on other options (see B<-text>, B<-token_out>). The default is
307 The output is a time stamp token (ContentInfo) instead of time stamp
308 response (TimeStampResp). (Optional)
312 If this option is specified the output is human-readable text format
313 instead of DER. (Optional)
317 Specifying an engine (by its unique B<id> string) will cause B<ts>
318 to attempt to obtain a functional reference to the specified engine,
319 thus initialising it if needed. The engine will then be set as the default
320 for all available algorithms. Default is builtin. (Optional)
324 =head2 Time Stamp Response verification
326 The B<-verify> command is for verifying if a time stamp response or time
327 stamp token is valid and matches a particular time stamp request or
328 data file. The B<-verify> command does not use the configuration file.
332 =item B<-data> file_to_hash
334 The response or token must be verified against file_to_hash. The file
335 is hashed with the message digest algorithm specified in the token.
336 The B<-digest> and B<-queryfile> options must not be specified with this one.
339 =item B<-digest> digest_bytes
341 The response or token must be verified against the message digest specified
342 with this option. The number of bytes must match the message digest algorithm
343 specified in the token. The B<-data> and B<-queryfile> options must not be
344 specified with this one. (Optional)
346 =item B<-queryfile> request.tsq
348 The original time stamp request in DER format. The B<-data> and B<-digest>
349 options must not be specified with this one. (Optional)
351 =item B<-in> response.tsr
353 The time stamp response that needs to be verified in DER format. (Mandatory)
357 This flag can be used together with the B<-in> option and indicates
358 that the input is a DER encoded time stamp token (ContentInfo) instead
359 of a time stamp response (TimeStampResp). (Optional)
361 =item B<-CApath> trusted_cert_path
363 The name of the directory containing the trusted CA certificates of the
364 client. See the similar option of L<verify(1)> for additional
365 details. Either this option or B<-CAfile> must be specified. (Optional)
368 =item B<-CAfile> trusted_certs.pem
370 The name of the file containing a set of trusted self-signed CA
371 certificates in PEM format. See the similar option of
372 L<verify(1)> for additional details. Either this option
373 or B<-CApath> must be specified.
376 =item B<-untrusted> cert_file.pem
378 Set of additional untrusted certificates in PEM format which may be
379 needed when building the certificate chain for the TSA's signing
380 certificate. This file must contain the TSA signing certificate and
381 all intermediate CA certificates unless the response includes them.
384 =item I<verify options>
386 The options B<-attime timestamp>, B<-check_ss_sig>, B<-crl_check>,
387 B<-crl_check_all>, B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>,
388 B<-inhibit_any>, B<-inhibit_map>, B<-issuer_checks>, B<-no_alt_chains>,
389 B<-no_check_time>, B<-partial_chain>, B<-policy>, B<-policy_check>,
390 B<-policy_print>, B<-purpose>, B<-suiteB_128>, B<-suiteB_128_only>,
391 B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>, B<-auth_level>,
392 B<-verify_depth>, B<-verify_email>, B<-verify_hostname>, B<-verify_ip>,
393 B<-verify_name>, and B<-x509_strict> can be used to control timestamp
394 verification. See L<verify(1)>.
398 =head1 CONFIGURATION FILE OPTIONS
400 The B<-query> and B<-reply> commands make use of a configuration file.
402 for a general description of the syntax of the config file. The
403 B<-query> command uses only the symbolic OID names section
404 and it can work without it. However, the B<-reply> command needs the
405 config file for its operation.
407 When there is a command line switch equivalent of a variable the
408 switch always overrides the settings in the config file.
412 =item B<tsa> section, B<default_tsa>
414 This is the main section and it specifies the name of another section
415 that contains all the options for the B<-reply> command. This default
416 section can be overridden with the B<-section> command line switch. (Optional)
420 See L<ca(1)> for description. (Optional)
424 See L<ca(1)> for description. (Optional)
428 See L<ca(1)> for description. (Optional)
432 The name of the file containing the hexadecimal serial number of the
433 last time stamp response created. This number is incremented by 1 for
434 each response. If the file does not exist at the time of response
435 generation a new file is created with serial number 1. (Mandatory)
437 =item B<crypto_device>
439 Specifies the OpenSSL engine that will be set as the default for
440 all available algorithms. The default value is builtin, you can specify
441 any other engines supported by OpenSSL (e.g. use chil for the NCipher HSM).
446 TSA signing certificate in PEM format. The same as the B<-signer>
447 command line option. (Optional)
451 A file containing a set of PEM encoded certificates that need to be
452 included in the response. The same as the B<-chain> command line
457 The private key of the TSA in PEM format. The same as the B<-inkey>
458 command line option. (Optional)
460 =item B<signer_digest>
462 Signing digest to use. The same as the
463 B<-I<digest>> command line option. (Optional)
465 =item B<default_policy>
467 The default policy to use when the request does not mandate any
468 policy. The same as the B<-tspolicy> command line option. (Optional)
470 =item B<other_policies>
472 Comma separated list of policies that are also acceptable by the TSA
473 and used only if the request explicitly specifies one of them. (Optional)
477 The list of message digest algorithms that the TSA accepts. At least
478 one algorithm must be specified. (Mandatory)
482 The accuracy of the time source of the TSA in seconds, milliseconds
483 and microseconds. E.g. secs:1, millisecs:500, microsecs:100. If any of
484 the components is missing zero is assumed for that field. (Optional)
486 =item B<clock_precision_digits>
488 Specifies the maximum number of digits, which represent the fraction of
489 seconds, that need to be included in the time field. The trailing zeroes
490 must be removed from the time, so there might actually be fewer digits,
491 or no fraction of seconds at all. Supported only on UNIX platforms.
492 The maximum value is 6, default is 0.
497 If this option is yes the responses generated by this TSA can always
498 be ordered, even if the time difference between two responses is less
499 than the sum of their accuracies. Default is no. (Optional)
503 Set this option to yes if the subject name of the TSA must be included in
504 the TSA name field of the response. Default is no. (Optional)
506 =item B<ess_cert_id_chain>
508 The SignedData objects created by the TSA always contain the
509 certificate identifier of the signing certificate in a signed
510 attribute (see RFC 2634, Enhanced Security Services). If this option
511 is set to yes and either the B<certs> variable or the B<-chain> option
512 is specified then the certificate identifiers of the chain will also
513 be included in the SigningCertificate signed attribute. If this
514 variable is set to no, only the signing certificate identifier is
515 included. Default is no. (Optional)
517 =item B<ess_cert_id_alg>
519 This option specifies the hash function to be used to calculate the TSA's
520 public key certificate identifier. Default is sha1. (Optional)
526 All the examples below presume that B<OPENSSL_CONF> is set to a proper
527 configuration file, e.g. the example configuration file
528 openssl/apps/openssl.cnf will do.
530 =head2 Time Stamp Request
532 To create a time stamp request for design1.txt with SHA-1
533 without nonce and policy and no certificate is required in the response:
535 openssl ts -query -data design1.txt -no_nonce \
538 To create a similar time stamp request with specifying the message imprint
541 openssl ts -query -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
542 -no_nonce -out design1.tsq
544 To print the content of the previous request in human readable format:
546 openssl ts -query -in design1.tsq -text
548 To create a time stamp request which includes the MD-5 digest
549 of design2.txt, requests the signer certificate and nonce,
550 specifies a policy id (assuming the tsa_policy1 name is defined in the
551 OID section of the config file):
553 openssl ts -query -data design2.txt -md5 \
554 -tspolicy tsa_policy1 -cert -out design2.tsq
556 =head2 Time Stamp Response
558 Before generating a response a signing certificate must be created for
559 the TSA that contains the B<timeStamping> critical extended key usage extension
560 without any other key usage extensions. You can add the
561 'extendedKeyUsage = critical,timeStamping' line to the user certificate section
562 of the config file to generate a proper certificate. See L<req(1)>,
563 L<ca(1)>, L<x509(1)> for instructions. The examples
564 below assume that cacert.pem contains the certificate of the CA,
565 tsacert.pem is the signing certificate issued by cacert.pem and
566 tsakey.pem is the private key of the TSA.
568 To create a time stamp response for a request:
570 openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \
571 -signer tsacert.pem -out design1.tsr
573 If you want to use the settings in the config file you could just write:
575 openssl ts -reply -queryfile design1.tsq -out design1.tsr
577 To print a time stamp reply to stdout in human readable format:
579 openssl ts -reply -in design1.tsr -text
581 To create a time stamp token instead of time stamp response:
583 openssl ts -reply -queryfile design1.tsq -out design1_token.der -token_out
585 To print a time stamp token to stdout in human readable format:
587 openssl ts -reply -in design1_token.der -token_in -text -token_out
589 To extract the time stamp token from a response:
591 openssl ts -reply -in design1.tsr -out design1_token.der -token_out
593 To add 'granted' status info to a time stamp token thereby creating a
596 openssl ts -reply -in design1_token.der -token_in -out design1.tsr
598 =head2 Time Stamp Verification
600 To verify a time stamp reply against a request:
602 openssl ts -verify -queryfile design1.tsq -in design1.tsr \
603 -CAfile cacert.pem -untrusted tsacert.pem
605 To verify a time stamp reply that includes the certificate chain:
607 openssl ts -verify -queryfile design2.tsq -in design2.tsr \
610 To verify a time stamp token against the original data file:
611 openssl ts -verify -data design2.txt -in design2.tsr \
614 To verify a time stamp token against a message imprint:
615 openssl ts -verify -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
616 -in design2.tsr -CAfile cacert.pem
618 You could also look at the 'test' directory for more examples.
622 =for comment foreign manuals: procmail(1), perl(1)
628 No support for time stamps over SMTP, though it is quite easy
629 to implement an automatic e-mail based TSA with L<procmail(1)>
630 and L<perl(1)>. HTTP server support is provided in the form of
631 a separate apache module. HTTP client support is provided by
632 L<tsget(1)>. Pure TCP/IP protocol is not supported.
636 The file containing the last serial number of the TSA is not
637 locked when being read or written. This is a problem if more than one
638 instance of L<openssl(1)> is trying to create a time stamp
639 response at the same time. This is not an issue when using the apache
640 server module, it does proper locking.
644 Look for the FIXME word in the source files.
648 The source code should really be reviewed by somebody else, too.
652 More testing is needed, I have done only some basic tests (see
659 L<tsget(1)>, L<openssl(1)>, L<req(1)>,
660 L<x509(1)>, L<ca(1)>, L<genrsa(1)>,
665 Copyright 2006-2017 The OpenSSL Project Authors. All Rights Reserved.
667 Licensed under the OpenSSL license (the "License"). You may not use
668 this file except in compliance with the License. You can obtain a copy
669 in the file LICENSE in the source distribution or at
670 L<https://www.openssl.org/source/license.html>.