2 {- OpenSSL::safe::output_do_not_edit_headers(); -}
6 openssl-ts - Time Stamping Authority command
15 [B<-config> I<configfile>]
16 [B<-data> I<file_to_hash>]
17 [B<-digest> I<digest_bytes>]
19 [B<-tspolicy> I<object_id>]
22 [B<-in> I<request.tsq>]
23 [B<-out> I<request.tsq>]
25 {- $OpenSSL::safe::opt_r_synopsis -}
26 {- $OpenSSL::safe::opt_provider_synopsis -}
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<filename>|I<uri>]
37 [B<-chain> I<certs_file.pem>]
38 [B<-tspolicy> I<object_id>]
39 [B<-in> I<response.tsr>]
41 [B<-out> I<response.tsr>]
44 {- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_provider_synopsis -}
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>]
53 [B<-untrusted> I<files>|I<uris>]
57 {- $OpenSSL::safe::opt_v_synopsis -}
58 {- $OpenSSL::safe::opt_provider_synopsis -}
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:
72 The TSA client computes a one-way hash value for a data file and sends
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.
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.
90 There is one DER encoded protocol data unit defined for transporting a
91 timestamp 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.
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.
107 Print out a usage message.
111 Generate a TS query. For details see L</Timestamp Request generation>.
115 Generate a TS reply. For details see L</Timestamp Response generation>.
119 Verify a TS response. For details see L</Timestamp Response verification>.
123 =head2 Timestamp Request generation
125 The B<-query> command can be used for creating and printing a timestamp
126 request with the following options:
130 =item B<-config> I<configfile>
132 The configuration file to use.
133 Optional; for a description of the default value,
134 see L<openssl(1)/COMMAND SUMMARY>.
136 =item B<-data> I<file_to_hash>
138 The data file for which the timestamp request needs to be
139 created. stdin is the default if neither the B<-data> nor the B<-digest>
140 parameter is specified. (Optional)
142 =item B<-digest> I<digest_bytes>
144 It is possible to specify the message imprint explicitly without the data
145 file. The imprint must be specified in a hexadecimal format, two characters
146 per byte, the bytes optionally separated by colons (e.g. 1A:F6:01:... or
147 1AF601...). The number of bytes must match the message digest algorithm
152 The message digest to apply to the data file.
153 Any digest supported by the L<openssl-dgst(1)> command can be used.
154 The default is SHA-256. (Optional)
156 =item B<-tspolicy> I<object_id>
158 The policy that the client expects the TSA to use for creating the
159 timestamp token. Either the dotted OID notation or OID names defined
160 in the config file can be used. If no policy is requested the TSA will
161 use its own default policy. (Optional)
165 No nonce is specified in the request if this option is
166 given. Otherwise, a 64-bit long pseudo-random nonce is
167 included in the request. It is recommended to use a nonce to
168 protect against replay attacks. (Optional)
172 The TSA is expected to include its signing certificate in the
175 =item B<-in> I<request.tsq>
177 This option specifies a previously created timestamp request in DER
178 format that will be printed into the output file. Useful when you need
179 to examine the content of a request in human-readable
182 =item B<-out> I<request.tsq>
184 Name of the output file to which the request will be written. Default
185 is stdout. (Optional)
189 If this option is specified the output is human-readable text format
190 instead of DER. (Optional)
192 {- $OpenSSL::safe::opt_r_item -}
196 =head2 Timestamp Response generation
198 A timestamp response (TimeStampResp) consists of a response status
199 and the timestamp token itself (ContentInfo), if the token generation was
200 successful. The B<-reply> command is for creating a timestamp
201 response or timestamp token based on a request and printing the
202 response/token in human-readable format. If B<-token_out> is not
203 specified the output is always a timestamp response (TimeStampResp),
204 otherwise it is a timestamp token (ContentInfo).
208 =item B<-config> I<configfile>
210 The configuration file to use.
211 Optional; for a description of the default value,
212 see L<openssl(1)/COMMAND SUMMARY>.
213 See L</CONFIGURATION FILE OPTIONS> for configurable variables.
215 =item B<-section> I<tsa_section>
217 The name of the config file section containing the settings for the
218 response generation. If not specified the default TSA section is
219 used, see L</CONFIGURATION FILE OPTIONS> for details. (Optional)
221 =item B<-queryfile> I<request.tsq>
223 The name of the file containing a DER encoded timestamp request. (Optional)
225 =item B<-passin> I<password_src>
227 Specifies the password source for the private key of the TSA. See
228 description in L<openssl(1)>. (Optional)
230 =item B<-signer> I<tsa_cert.pem>
232 The signer certificate of the TSA in PEM format. The TSA signing
233 certificate must have exactly one extended key usage assigned to it:
234 timeStamping. The extended key usage must also be critical, otherwise
235 the certificate is going to be refused. Overrides the B<signer_cert>
236 variable of the config file. (Optional)
238 =item B<-inkey> I<filename>|I<uri>
240 The signer private key of the TSA in PEM format. Overrides the
241 B<signer_key> config file option. (Optional)
245 Signing digest to use. Overrides the B<signer_digest> config file
246 option. (Mandatory unless specified in the config file)
248 =item B<-chain> I<certs_file.pem>
250 The collection of certificates in PEM format that will all
251 be included in the response in addition to the signer certificate if
252 the B<-cert> option was used for the request. This file is supposed to
253 contain the certificate chain for the signer certificate from its
254 issuer upwards. The B<-reply> command does not build a certificate
255 chain automatically. (Optional)
257 =item B<-tspolicy> I<object_id>
259 The default policy to use for the response unless the client
260 explicitly requires a particular TSA policy. The OID can be specified
261 either in dotted notation or with its name. Overrides the
262 B<default_policy> config file option. (Optional)
264 =item B<-in> I<response.tsr>
266 Specifies a previously created timestamp response or timestamp token
267 (if B<-token_in> is also specified) in DER format that will be written
268 to the output file. This option does not require a request, it is
269 useful e.g. when you need to examine the content of a response or
270 token or you want to extract the timestamp token from a response. If
271 the input is a token and the output is a timestamp response a default
272 'granted' status info is added to the token. (Optional)
276 This flag can be used together with the B<-in> option and indicates
277 that the input is a DER encoded timestamp token (ContentInfo) instead
278 of a timestamp response (TimeStampResp). (Optional)
280 =item B<-out> I<response.tsr>
282 The response is written to this file. The format and content of the
283 file depends on other options (see B<-text>, B<-token_out>). The default is
288 The output is a timestamp token (ContentInfo) instead of timestamp
289 response (TimeStampResp). (Optional)
293 If this option is specified the output is human-readable text format
294 instead of DER. (Optional)
296 {- $OpenSSL::safe::opt_engine_item -}
298 {- $OpenSSL::safe::opt_provider_item -}
302 =head2 Timestamp Response verification
304 The B<-verify> command is for verifying if a timestamp response or
305 timestamp token is valid and matches a particular timestamp request or
306 data file. The B<-verify> command does not use the configuration file.
310 =item B<-data> I<file_to_hash>
312 The response or token must be verified against file_to_hash. The file
313 is hashed with the message digest algorithm specified in the token.
314 The B<-digest> and B<-queryfile> options must not be specified with this one.
317 =item B<-digest> I<digest_bytes>
319 The response or token must be verified against the message digest specified
320 with this option. The number of bytes must match the message digest algorithm
321 specified in the token. The B<-data> and B<-queryfile> options must not be
322 specified with this one. (Optional)
324 =item B<-queryfile> I<request.tsq>
326 The original timestamp request in DER format. The B<-data> and B<-digest>
327 options must not be specified with this one. (Optional)
329 =item B<-in> I<response.tsr>
331 The timestamp response that needs to be verified in DER format. (Mandatory)
335 This flag can be used together with the B<-in> option and indicates
336 that the input is a DER encoded timestamp token (ContentInfo) instead
337 of a timestamp response (TimeStampResp). (Optional)
339 =item B<-untrusted> I<files>|I<uris>
341 A set of additional untrusted certificates which may be
342 needed when building the certificate chain for the TSA's signing certificate.
343 These do not need to contain the TSA signing certificate and intermediate CA
344 certificates as far as the response already includes them.
347 Multiple sources may be given, separated by commas and/or whitespace.
348 Each file may contain multiple certificates.
350 =item B<-CAfile> I<file>, B<-CApath> I<dir>, B<-CAstore> I<uri>
352 See L<openssl-verification-options(1)/Trusted Certificate Options> for details.
353 At least one of B<-CAfile>, B<-CApath> or B<-CAstore> must be specified.
355 {- $OpenSSL::safe::opt_v_item -}
357 Any verification errors cause the command to exit.
361 =head1 CONFIGURATION FILE OPTIONS
363 The B<-query> and B<-reply> commands make use of a configuration file.
365 for a general description of the syntax of the config file. The
366 B<-query> command uses only the symbolic OID names section
367 and it can work without it. However, the B<-reply> command needs the
368 config file for its operation.
370 When there is a command line switch equivalent of a variable the
371 switch always overrides the settings in the config file.
375 =item B<tsa> section, B<default_tsa>
377 This is the main section and it specifies the name of another section
378 that contains all the options for the B<-reply> command. This default
379 section can be overridden with the B<-section> command line switch. (Optional)
383 This specifies a file containing additional B<OBJECT IDENTIFIERS>.
384 Each line of the file should consist of the numerical form of the
385 object identifier followed by whitespace then the short name followed
386 by whitespace and finally the long name. (Optional)
390 This specifies a section in the configuration file containing extra
391 object identifiers. Each line should consist of the short name of the
392 object identifier followed by B<=> and the numerical form. The short
393 and long names are the same when this option is used. (Optional)
397 At startup the specified file is loaded into the random number generator,
398 and at exit 256 bytes will be written to it. (Note: Using a RANDFILE is
399 not necessary anymore, see the L</HISTORY> section.
403 The name of the file containing the hexadecimal serial number of the
404 last timestamp response created. This number is incremented by 1 for
405 each response. If the file does not exist at the time of response
406 generation a new file is created with serial number 1. (Mandatory)
408 =item B<crypto_device>
410 Specifies the OpenSSL engine that will be set as the default for
411 all available algorithms. The default value is built-in, you can specify
412 any other engines supported by OpenSSL (e.g. use chil for the NCipher HSM).
417 TSA signing certificate in PEM format. The same as the B<-signer>
418 command line option. (Optional)
422 A file containing a set of PEM encoded certificates that need to be
423 included in the response. The same as the B<-chain> command line
428 The private key of the TSA in PEM format. The same as the B<-inkey>
429 command line option. (Optional)
431 =item B<signer_digest>
433 Signing digest to use. The same as the
434 B<-I<digest>> command line option. (Mandatory unless specified on the command
437 =item B<default_policy>
439 The default policy to use when the request does not mandate any
440 policy. The same as the B<-tspolicy> command line option. (Optional)
442 =item B<other_policies>
444 Comma separated list of policies that are also acceptable by the TSA
445 and used only if the request explicitly specifies one of them. (Optional)
449 The list of message digest algorithms that the TSA accepts. At least
450 one algorithm must be specified. (Mandatory)
454 The accuracy of the time source of the TSA in seconds, milliseconds
455 and microseconds. E.g. secs:1, millisecs:500, microsecs:100. If any of
456 the components is missing zero is assumed for that field. (Optional)
458 =item B<clock_precision_digits>
460 Specifies the maximum number of digits, which represent the fraction of
461 seconds, that need to be included in the time field. The trailing zeros
462 must be removed from the time, so there might actually be fewer digits,
463 or no fraction of seconds at all. Supported only on UNIX platforms.
464 The maximum value is 6, default is 0.
469 If this option is yes the responses generated by this TSA can always
470 be ordered, even if the time difference between two responses is less
471 than the sum of their accuracies. Default is no. (Optional)
475 Set this option to yes if the subject name of the TSA must be included in
476 the TSA name field of the response. Default is no. (Optional)
478 =item B<ess_cert_id_chain>
480 The SignedData objects created by the TSA always contain the
481 certificate identifier of the signing certificate in a signed
482 attribute (see RFC 2634, Enhanced Security Services).
483 If this variable is set to no, only this signing certificate identifier
484 is included in the SigningCertificate signed attribute.
485 If this variable is set to yes and the B<certs> variable or the B<-chain> option
486 is specified then the certificate identifiers of the chain will also
487 be included, where the B<-chain> option overrides the B<certs> variable.
488 Default is no. (Optional)
490 =item B<ess_cert_id_alg>
492 This option specifies the hash function to be used to calculate the TSA's
493 public key certificate identifier. Default is sha256. (Optional)
499 All the examples below presume that B<OPENSSL_CONF> is set to a proper
500 configuration file, e.g. the example configuration file
501 F<openssl/apps/openssl.cnf> will do.
503 =head2 Timestamp Request
505 To create a timestamp request for F<design1.txt> with SHA-256 digest,
506 without nonce and policy, and without requirement for a certificate
509 openssl ts -query -data design1.txt -no_nonce \
512 To create a similar timestamp request with specifying the message imprint
515 openssl ts -query -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
516 -no_nonce -out design1.tsq
518 To print the content of the previous request in human readable format:
520 openssl ts -query -in design1.tsq -text
522 To create a timestamp request which includes the SHA-512 digest
523 of F<design2.txt>, requests the signer certificate and nonce, and
524 specifies a policy id (assuming the tsa_policy1 name is defined in the
525 OID section of the config file):
527 openssl ts -query -data design2.txt -sha512 \
528 -tspolicy tsa_policy1 -cert -out design2.tsq
530 =head2 Timestamp Response
532 Before generating a response a signing certificate must be created for
533 the TSA that contains the B<timeStamping> critical extended key usage extension
534 without any other key usage extensions. You can add this line to the
535 user certificate section of the config file to generate a proper certificate;
537 extendedKeyUsage = critical,timeStamping
539 See L<openssl-req(1)>, L<openssl-ca(1)>, and L<openssl-x509(1)> for
540 instructions. The examples below assume that F<cacert.pem> contains the
541 certificate of the CA, F<tsacert.pem> is the signing certificate issued
542 by F<cacert.pem> and F<tsakey.pem> is the private key of the TSA.
544 To create a timestamp response for a request:
546 openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \
547 -signer tsacert.pem -out design1.tsr
549 If you want to use the settings in the config file you could just write:
551 openssl ts -reply -queryfile design1.tsq -out design1.tsr
553 To print a timestamp reply to stdout in human readable format:
555 openssl ts -reply -in design1.tsr -text
557 To create a timestamp token instead of timestamp response:
559 openssl ts -reply -queryfile design1.tsq -out design1_token.der -token_out
561 To print a timestamp token to stdout in human readable format:
563 openssl ts -reply -in design1_token.der -token_in -text -token_out
565 To extract the timestamp token from a response:
567 openssl ts -reply -in design1.tsr -out design1_token.der -token_out
569 To add 'granted' status info to a timestamp token thereby creating a
572 openssl ts -reply -in design1_token.der -token_in -out design1.tsr
574 =head2 Timestamp Verification
576 To verify a timestamp reply against a request:
578 openssl ts -verify -queryfile design1.tsq -in design1.tsr \
579 -CAfile cacert.pem -untrusted tsacert.pem
581 To verify a timestamp reply that includes the certificate chain:
583 openssl ts -verify -queryfile design2.tsq -in design2.tsr \
586 To verify a timestamp token against the original data file:
587 openssl ts -verify -data design2.txt -in design2.tsr \
590 To verify a timestamp token against a message imprint:
591 openssl ts -verify -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
592 -in design2.tsr -CAfile cacert.pem
594 You could also look at the 'test' directory for more examples.
598 =for openssl foreign manual procmail(1) perl(1)
604 No support for timestamps over SMTP, though it is quite easy
605 to implement an automatic e-mail based TSA with L<procmail(1)>
606 and L<perl(1)>. HTTP server support is provided in the form of
607 a separate apache module. HTTP client support is provided by
608 L<tsget(1)>. Pure TCP/IP protocol is not supported.
612 The file containing the last serial number of the TSA is not
613 locked when being read or written. This is a problem if more than one
614 instance of L<openssl(1)> is trying to create a timestamp
615 response at the same time. This is not an issue when using the apache
616 server module, it does proper locking.
620 Look for the FIXME word in the source files.
624 The source code should really be reviewed by somebody else, too.
628 More testing is needed, I have done only some basic tests (see
635 OpenSSL 1.1.1 introduced a new random generator (CSPRNG) with an improved
636 seeding mechanism. The new seeding mechanism makes it unnecessary to
637 define a RANDFILE for saving and restoring randomness. This option is
638 retained mainly for compatibility reasons.
640 The B<-engine> option was deprecated in OpenSSL 3.0.
649 L<openssl-genrsa(1)>,
651 L<ossl_store-file(7)>
655 Copyright 2006-2024 The OpenSSL Project Authors. All Rights Reserved.
657 Licensed under the Apache License 2.0 (the "License"). You may not use
658 this file except in compliance with the License. You can obtain a copy
659 in the file LICENSE in the source distribution or at
660 L<https://www.openssl.org/source/license.html>.