4 {- join("\n", @autowarntext) -}
10 openssl-ts - Time Stamping Authority tool (client/server)
16 [B<-config> I<configfile>]
17 [B<-data> I<file_to_hash>]
18 [B<-digest> I<digest_bytes>]
20 [B<-tspolicy> I<object_id>]
23 [B<-in> I<request.tsq>]
24 [B<-out> I<request.tsq>]
26 {- $OpenSSL::safe::opt_r_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<file_or_id>]
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>]
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<-CApath> I<trusted_cert_path>]
54 [B<-CAfile> I<trusted_certs.pem>]
55 [B<-CAstore> I<trusted_certs_uri>]
56 [B<-untrusted> I<cert_file.pem>]
60 [B<-attime> I<timestamp>]
76 [B<-purpose> I<purpose>]
82 [B<-auth_level> I<num>]
83 [B<-verify_depth> I<num>]
84 [B<-verify_email> I<email>]
85 [B<-verify_hostname> I<hostname>]
87 [B<-verify_name> I<name>]
90 =for openssl ifdef engine
94 This command is a basic Time Stamping Authority (TSA) client and
95 server application as specified in RFC 3161 (Time-Stamp Protocol, TSP). A
96 TSA can be part of a PKI deployment and its role is to provide long
97 term proof of the existence of a certain datum before a particular
98 time. Here is a brief description of the protocol:
104 The TSA client computes a one-way hash value for a data file and sends
109 The TSA attaches the current date and time to the received hash value,
110 signs them and sends the timestamp token back to the client. By
111 creating this token the TSA certifies the existence of the original
112 data file at the time of response generation.
116 The TSA client receives the timestamp token and verifies the
117 signature on it. It also checks if the token contains the same hash
118 value that it had sent to the TSA.
122 There is one DER encoded protocol data unit defined for transporting a time
123 stamp request to the TSA and one for sending the timestamp response
124 back to the client. This command has three main functions:
125 creating a timestamp request based on a data file,
126 creating a timestamp response based on a request, verifying if a
127 response corresponds to a particular request or a data file.
129 There is no support for sending the requests/responses automatically
130 over HTTP or TCP yet as suggested in RFC 3161. The users must send the
131 requests either by ftp or e-mail.
135 =head2 Timestamp Request generation
137 The B<-query> switch can be used for creating and printing a timestamp
138 request with the following options:
142 =item B<-config> I<configfile>
144 The configuration file to use.
145 Optional; for a description of the default value,
146 see L<openssl(1)/COMMAND SUMMARY>.
148 =item B<-data> I<file_to_hash>
150 The data file for which the timestamp request needs to be
151 created. stdin is the default if neither the B<-data> nor the B<-digest>
152 parameter is specified. (Optional)
154 =item B<-digest> I<digest_bytes>
156 It is possible to specify the message imprint explicitly without the data
157 file. The imprint must be specified in a hexadecimal format, two characters
158 per byte, the bytes optionally separated by colons (e.g. 1A:F6:01:... or
159 1AF601...). The number of bytes must match the message digest algorithm
164 The message digest to apply to the data file.
165 Any digest supported by the L<openssl-dgst(1)> command can be used.
166 The default is SHA-256. (Optional)
168 =item B<-tspolicy> I<object_id>
170 The policy that the client expects the TSA to use for creating the
171 timestamp token. Either the dotted OID notation or OID names defined
172 in the config file can be used. If no policy is requested the TSA will
173 use its own default policy. (Optional)
177 No nonce is specified in the request if this option is
178 given. Otherwise a 64 bit long pseudo-random none is
179 included in the request. It is recommended to use nonce to
180 protect against replay-attacks. (Optional)
184 The TSA is expected to include its signing certificate in the
187 =item B<-in> I<request.tsq>
189 This option specifies a previously created timestamp request in DER
190 format that will be printed into the output file. Useful when you need
191 to examine the content of a request in human-readable
194 =item B<-out> I<request.tsq>
196 Name of the output file to which the request will be written. Default
197 is stdout. (Optional)
201 If this option is specified the output is human-readable text format
202 instead of DER. (Optional)
204 {- $OpenSSL::safe::opt_r_item -}
208 =head2 Timestamp Response generation
210 A timestamp response (TimeStampResp) consists of a response status
211 and the timestamp token itself (ContentInfo), if the token generation was
212 successful. The B<-reply> command is for creating a timestamp
213 response or timestamp token based on a request and printing the
214 response/token in human-readable format. If B<-token_out> is not
215 specified the output is always a timestamp response (TimeStampResp),
216 otherwise it is a timestamp token (ContentInfo).
220 =item B<-config> I<configfile>
222 The configuration file to use.
223 Optional; for a description of the default value,
224 see L<openssl(1)/COMMAND SUMMARY>.
225 See L</CONFIGURATION FILE OPTIONS> for configurable variables.
227 =item B<-section> I<tsa_section>
229 The name of the config file section containing the settings for the
230 response generation. If not specified the default TSA section is
231 used, see L</CONFIGURATION FILE OPTIONS> for details. (Optional)
233 =item B<-queryfile> I<request.tsq>
235 The name of the file containing a DER encoded timestamp request. (Optional)
237 =item B<-passin> I<password_src>
239 Specifies the password source for the private key of the TSA. See
240 description in L<openssl(1)>. (Optional)
242 =item B<-signer> I<tsa_cert.pem>
244 The signer certificate of the TSA in PEM format. The TSA signing
245 certificate must have exactly one extended key usage assigned to it:
246 timeStamping. The extended key usage must also be critical, otherwise
247 the certificate is going to be refused. Overrides the B<signer_cert>
248 variable of the config file. (Optional)
250 =item B<-inkey> I<file_or_id>
252 The signer private key of the TSA in PEM format. Overrides the
253 B<signer_key> config file option. (Optional)
254 If no engine is used, the argument is taken as a file; if an engine is
255 specified, the argument is given to the engine as a key identifier.
259 Signing digest to use. Overrides the B<signer_digest> config file
260 option. (Mandatory unless specified in the config file)
262 =item B<-chain> I<certs_file.pem>
264 The collection of certificates in PEM format that will all
265 be included in the response in addition to the signer certificate if
266 the B<-cert> option was used for the request. This file is supposed to
267 contain the certificate chain for the signer certificate from its
268 issuer upwards. The B<-reply> command does not build a certificate
269 chain automatically. (Optional)
271 =item B<-tspolicy> I<object_id>
273 The default policy to use for the response unless the client
274 explicitly requires a particular TSA policy. The OID can be specified
275 either in dotted notation or with its name. Overrides the
276 B<default_policy> config file option. (Optional)
278 =item B<-in> I<response.tsr>
280 Specifies a previously created timestamp response or timestamp token
281 (if B<-token_in> is also specified) in DER format that will be written
282 to the output file. This option does not require a request, it is
283 useful e.g. when you need to examine the content of a response or
284 token or you want to extract the timestamp token from a response. If
285 the input is a token and the output is a timestamp response a default
286 'granted' status info is added to the token. (Optional)
290 This flag can be used together with the B<-in> option and indicates
291 that the input is a DER encoded timestamp token (ContentInfo) instead
292 of a timestamp response (TimeStampResp). (Optional)
294 =item B<-out> I<response.tsr>
296 The response is written to this file. The format and content of the
297 file depends on other options (see B<-text>, B<-token_out>). The default is
302 The output is a timestamp token (ContentInfo) instead of timestamp
303 response (TimeStampResp). (Optional)
307 If this option is specified the output is human-readable text format
308 instead of DER. (Optional)
310 =item B<-engine> I<id>
312 Specifying an engine (by its unique I<id> string) will cause this command
313 to attempt to obtain a functional reference to the specified engine,
314 thus initialising it if needed. The engine will then be set as the default
315 for all available algorithms. Default is built-in. (Optional)
319 =head2 Timestamp Response verification
321 The B<-verify> command is for verifying if a timestamp response or time
322 stamp token is valid and matches a particular timestamp request or
323 data file. The B<-verify> command does not use the configuration file.
327 =item B<-data> I<file_to_hash>
329 The response or token must be verified against file_to_hash. The file
330 is hashed with the message digest algorithm specified in the token.
331 The B<-digest> and B<-queryfile> options must not be specified with this one.
334 =item B<-digest> I<digest_bytes>
336 The response or token must be verified against the message digest specified
337 with this option. The number of bytes must match the message digest algorithm
338 specified in the token. The B<-data> and B<-queryfile> options must not be
339 specified with this one. (Optional)
341 =item B<-queryfile> I<request.tsq>
343 The original timestamp request in DER format. The B<-data> and B<-digest>
344 options must not be specified with this one. (Optional)
346 =item B<-in> I<response.tsr>
348 The timestamp response that needs to be verified in DER format. (Mandatory)
352 This flag can be used together with the B<-in> option and indicates
353 that the input is a DER encoded timestamp token (ContentInfo) instead
354 of a timestamp response (TimeStampResp). (Optional)
356 =item B<-CAfile> I<file>, B<-CApath> I<dir>, B<-CAstore> I<uri>
358 See L<openssl(1)/Trusted Certificate Options> for more information.
360 At least one of B<-CApath>, B<-CAfile> or B<-CAstore> must be specified.
362 =item B<-untrusted> I<cert_file.pem>
364 Set of additional untrusted certificates in PEM format which may be
365 needed when building the certificate chain for the TSA's signing
366 certificate. This file must contain the TSA signing certificate and
367 all intermediate CA certificates unless the response includes them.
370 =item I<verify options>
372 The options B<-attime>, B<-check_ss_sig>, B<-crl_check>,
373 B<-crl_check_all>, B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>,
374 B<-inhibit_any>, B<-inhibit_map>, B<-issuer_checks>, B<-no_alt_chains>,
375 B<-no_check_time>, B<-partial_chain>, B<-policy>, B<-policy_check>,
376 B<-policy_print>, B<-purpose>, B<-suiteB_128>, B<-suiteB_128_only>,
377 B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>, B<-auth_level>,
378 B<-verify_depth>, B<-verify_email>, B<-verify_hostname>, B<-verify_ip>,
379 B<-verify_name>, and B<-x509_strict> can be used to control timestamp
380 verification. See L<openssl-verify(1)>.
384 =head1 CONFIGURATION FILE OPTIONS
386 The B<-query> and B<-reply> commands make use of a configuration file.
388 for a general description of the syntax of the config file. The
389 B<-query> command uses only the symbolic OID names section
390 and it can work without it. However, the B<-reply> command needs the
391 config file for its operation.
393 When there is a command line switch equivalent of a variable the
394 switch always overrides the settings in the config file.
398 =item B<tsa> section, B<default_tsa>
400 This is the main section and it specifies the name of another section
401 that contains all the options for the B<-reply> command. This default
402 section can be overridden with the B<-section> command line switch. (Optional)
406 See L<openssl-ca(1)> for description. (Optional)
410 See L<openssl-ca(1)> for description. (Optional)
414 See L<openssl-ca(1)> for description. (Optional)
418 The name of the file containing the hexadecimal serial number of the
419 last timestamp response created. This number is incremented by 1 for
420 each response. If the file does not exist at the time of response
421 generation a new file is created with serial number 1. (Mandatory)
423 =item B<crypto_device>
425 Specifies the OpenSSL engine that will be set as the default for
426 all available algorithms. The default value is built-in, you can specify
427 any other engines supported by OpenSSL (e.g. use chil for the NCipher HSM).
432 TSA signing certificate in PEM format. The same as the B<-signer>
433 command line option. (Optional)
437 A file containing a set of PEM encoded certificates that need to be
438 included in the response. The same as the B<-chain> command line
443 The private key of the TSA in PEM format. The same as the B<-inkey>
444 command line option. (Optional)
446 =item B<signer_digest>
448 Signing digest to use. The same as the
449 B<-I<digest>> command line option. (Mandatory unless specified on the command
452 =item B<default_policy>
454 The default policy to use when the request does not mandate any
455 policy. The same as the B<-tspolicy> command line option. (Optional)
457 =item B<other_policies>
459 Comma separated list of policies that are also acceptable by the TSA
460 and used only if the request explicitly specifies one of them. (Optional)
464 The list of message digest algorithms that the TSA accepts. At least
465 one algorithm must be specified. (Mandatory)
469 The accuracy of the time source of the TSA in seconds, milliseconds
470 and microseconds. E.g. secs:1, millisecs:500, microsecs:100. If any of
471 the components is missing zero is assumed for that field. (Optional)
473 =item B<clock_precision_digits>
475 Specifies the maximum number of digits, which represent the fraction of
476 seconds, that need to be included in the time field. The trailing zeros
477 must be removed from the time, so there might actually be fewer digits,
478 or no fraction of seconds at all. Supported only on UNIX platforms.
479 The maximum value is 6, default is 0.
484 If this option is yes the responses generated by this TSA can always
485 be ordered, even if the time difference between two responses is less
486 than the sum of their accuracies. Default is no. (Optional)
490 Set this option to yes if the subject name of the TSA must be included in
491 the TSA name field of the response. Default is no. (Optional)
493 =item B<ess_cert_id_chain>
495 The SignedData objects created by the TSA always contain the
496 certificate identifier of the signing certificate in a signed
497 attribute (see RFC 2634, Enhanced Security Services). If this option
498 is set to yes and either the B<certs> variable or the B<-chain> option
499 is specified then the certificate identifiers of the chain will also
500 be included in the SigningCertificate signed attribute. If this
501 variable is set to no, only the signing certificate identifier is
502 included. Default is no. (Optional)
504 =item B<ess_cert_id_alg>
506 This option specifies the hash function to be used to calculate the TSA's
507 public key certificate identifier. Default is sha256. (Optional)
513 All the examples below presume that B<OPENSSL_CONF> is set to a proper
514 configuration file, e.g. the example configuration file
515 F<openssl/apps/openssl.cnf> will do.
517 =head2 Timestamp Request
519 To create a timestamp request for F<design1.txt> with SHA-256 digest,
520 without nonce and policy, and without requirement for a certificate
523 openssl ts -query -data design1.txt -no_nonce \
526 To create a similar timestamp request with specifying the message imprint
529 openssl ts -query -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
530 -no_nonce -out design1.tsq
532 To print the content of the previous request in human readable format:
534 openssl ts -query -in design1.tsq -text
536 To create a timestamp request which includes the SHA-512 digest
537 of F<design2.txt>, requests the signer certificate and nonce, and
538 specifies a policy id (assuming the tsa_policy1 name is defined in the
539 OID section of the config file):
541 openssl ts -query -data design2.txt -sha512 \
542 -tspolicy tsa_policy1 -cert -out design2.tsq
544 =head2 Timestamp Response
546 Before generating a response a signing certificate must be created for
547 the TSA that contains the B<timeStamping> critical extended key usage extension
548 without any other key usage extensions. You can add this line to the
549 user certificate section of the config file to generate a proper certificate;
551 extendedKeyUsage = critical,timeStamping
553 See L<openssl-req(1)>, L<openssl-ca(1)>, and L<openssl-x509(1)> for
554 instructions. The examples below assume that F<cacert.pem> contains the
555 certificate of the CA, F<tsacert.pem> is the signing certificate issued
556 by F<cacert.pem> and F<tsakey.pem> is the private key of the TSA.
558 To create a timestamp response for a request:
560 openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \
561 -signer tsacert.pem -out design1.tsr
563 If you want to use the settings in the config file you could just write:
565 openssl ts -reply -queryfile design1.tsq -out design1.tsr
567 To print a timestamp reply to stdout in human readable format:
569 openssl ts -reply -in design1.tsr -text
571 To create a timestamp token instead of timestamp response:
573 openssl ts -reply -queryfile design1.tsq -out design1_token.der -token_out
575 To print a timestamp token to stdout in human readable format:
577 openssl ts -reply -in design1_token.der -token_in -text -token_out
579 To extract the timestamp token from a response:
581 openssl ts -reply -in design1.tsr -out design1_token.der -token_out
583 To add 'granted' status info to a timestamp token thereby creating a
586 openssl ts -reply -in design1_token.der -token_in -out design1.tsr
588 =head2 Timestamp Verification
590 To verify a timestamp reply against a request:
592 openssl ts -verify -queryfile design1.tsq -in design1.tsr \
593 -CAfile cacert.pem -untrusted tsacert.pem
595 To verify a timestamp reply that includes the certificate chain:
597 openssl ts -verify -queryfile design2.tsq -in design2.tsr \
600 To verify a timestamp token against the original data file:
601 openssl ts -verify -data design2.txt -in design2.tsr \
604 To verify a timestamp token against a message imprint:
605 openssl ts -verify -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
606 -in design2.tsr -CAfile cacert.pem
608 You could also look at the 'test' directory for more examples.
612 =for openssl foreign manuals: procmail(1), perl(1)
618 No support for timestamps over SMTP, though it is quite easy
619 to implement an automatic e-mail based TSA with L<procmail(1)>
620 and L<perl(1)>. HTTP server support is provided in the form of
621 a separate apache module. HTTP client support is provided by
622 L<tsget(1)>. Pure TCP/IP protocol is not supported.
626 The file containing the last serial number of the TSA is not
627 locked when being read or written. This is a problem if more than one
628 instance of L<openssl(1)> is trying to create a timestamp
629 response at the same time. This is not an issue when using the apache
630 server module, it does proper locking.
634 Look for the FIXME word in the source files.
638 The source code should really be reviewed by somebody else, too.
642 More testing is needed, I have done only some basic tests (see
654 L<openssl-genrsa(1)>,
656 L<ossl_store-file(7)>
660 Copyright 2006-2019 The OpenSSL Project Authors. All Rights Reserved.
662 Licensed under the Apache License 2.0 (the "License"). You may not use
663 this file except in compliance with the License. You can obtain a copy
664 in the file LICENSE in the source distribution or at
665 L<https://www.openssl.org/source/license.html>.