OPENSSL-TS(1ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… NAME πŸ’…

okay bestie, meet openssl-ts β€” the Time Stamping Authority command from OPENSSL-TS(1ossl). It's giving β€œyour fave is literally a whole TSA client and server application,” and we're obsessed. πŸ’–

✨ SYNOPSIS ✨

openssl ts -help

openssl ts -query [-config configfile] [-data file_to_hash] [-digest
digest_bytes] [-digest] [-tspolicy object_id] [-no_nonce] [-cert] [-in
request.tsq] [-out request.tsq] [-text] [-rand files] [-writerand file]
[-provider name] [-provider-path path] [-provparam [name:]key=value]
[-propquery propq]

openssl ts -reply [-config configfile] [-section tsa_section]
[-queryfile request.tsq] [-passin password_src] [-signer tsa_cert.pem]
[-inkey filename|uri] [-digest] [-chain certs_file.pem] [-tspolicy
object_id] [-in response.tsr] [-token_in] [-out response.tsr]
[-token_out] [-text] [-engine id] [-provider name] [-provider-path path]
[-provparam [name:]key=value] [-propquery propq]

openssl ts -verify [-data file_to_hash] [-digest digest_bytes]
[-queryfile request.tsq] [-in response.tsr] [-token_in] [-untrusted
files|uris] [-CAfile file] [-CApath dir] [-CAstore uri]
[-allow_proxy_certs] [-attime timestamp] [-no_check_time]
[-check_ss_sig] [-crl_check] [-crl_check_all] [-explicit_policy]
[-extended_crl] [-ignore_critical] [-inhibit_any] [-inhibit_map]
[-partial_chain] [-policy arg] [-policy_check] [-policy_print] [-purpose
purpose] [-suiteB_128] [-suiteB_128_only] [-suiteB_192] [-trusted_first]
[-no_alt_chains] [-use_deltas] [-auth_level num] [-verify_depth num]
[-verify_email email] [-verify_hostname hostname] [-verify_ip ip]
[-verify_name name] [-x509_strict] [-issuer_checks] [-provider name]
[-provider-path path] [-provparam [name:]key=value] [-propquery propq]

🌸 DESCRIPTION 🌸

so this command is a basic Time Stamping Authority (TSA) client and server application as specified in RFC 3161 (Time-Stamp Protocol, TSP). A TSA can be part of a PKI deployment, and its whole role is to provide long term proof of the existence of a certain datum before a particular time. 🫢

here's the protocol vibe check, bestie β€” brief description, no cap:

  1. The TSA client computes a one-way hash value for a data file and sends the hash to the TSA.
  2. The TSA attaches the current date and time to the received hash value, signs them and sends the timestamp token back to the client. By creating this token the TSA certifies the existence of the original data file at the time of response generation. ⏰✨
  3. The TSA client receives the timestamp token and verifies the signature on it. It also checks if the token contains the same hash value that it had sent to the TSA. πŸ”

there is one DER encoded protocol data unit defined for transporting a timestamp request to the TSA and one for sending the timestamp response back to the client. This command has three main functions: creating a timestamp request based on a data file, creating a timestamp response based on a request, verifying if a response corresponds to a particular request or a data file. πŸ’…

okay so important caveat, bestie: there is no support for sending the requests/responses automatically over HTTP or TCP yet as suggested in RFC 3161. The users must send the requests either by ftp or e-mail. 😭 no auto-slide-into-the-DMs for these requests, fr fr.

✨ OPTIONS ✨

Okay bestie, here's the full menu of flags. Buckle up, there's a lot, but every single one matters πŸ’…

  • -help β€” prints out a usage message, that's it, that's the whole vibe.
  • -query β€” generates a TS query. The full tea is in "Timestamp Request generation" below.
  • -reply β€” generates a TS reply. Details live in "Timestamp Response generation".
  • -verify β€” verifies a TS response. Scroll to "Timestamp Response verification" for the scoop.

πŸŽ€ Timestamp Request generation πŸŽ€

So the -query command is your go-to for creating and printing a timestamp request, and these are the options it rocks with:

  • -config configfile β€” the config file to use. It's optional; for what the default value actually is, peek at "COMMAND SUMMARY" in openssl(1).
  • -data file_to_hash β€” the data file you want the timestamp request made for. If you don't specify either -data or -digest, stdin is the default, no cap. (Optional)
  • -digest digest_bytes β€” yep, you can just hand over the message imprint explicitly without any data file at all. The imprint goes in hexadecimal, two characters per byte, and the bytes can optionally be separated by colons (like 1A:F6:01:... or 1AF601...). The number of bytes has to match the message digest algorithm you're using, fr fr. (Optional)
  • -digest β€” the message digest to apply to the data file. Any digest that openssl-dgst(1) supports is fair game. Default is SHA-256. (Optional)
  • -tspolicy object_id β€” the policy the client expects the TSA to use when it makes the timestamp token. You can write it in dotted OID notation or as an OID name defined in the config file. If you don't request a policy, the TSA just uses its own default policy, periodt. (Optional)
  • -no_nonce β€” if you pass this, no nonce goes in the request. Otherwise a 64-bit long pseudo-random nonce gets included. Highly recommend using a nonce to protect against replay attacks, bestie, it's giving safety. (Optional)
  • -cert β€” the TSA is expected to include its signing certificate in the response. (Optional)
  • -in request.tsq β€” points at a previously created timestamp request in DER format that'll get printed into the output file. Super useful when you need to examine a request's content in human-readable format. (Optional)
  • -out request.tsq β€” the name of the output file the request gets written to. Default is stdout. (Optional)
  • -text β€” if you specify this, the output is human-readable text format instead of DER. (Optional)
  • -rand files, -writerand file β€” see "Random State Options" in openssl(1) for the details.

🌸 Timestamp Response generation 🌸

A timestamp response (TimeStampResp) is made of a response status plus the timestamp token itself (ContentInfo) β€” that second part only shows up if the token generation actually succeeded. The -reply command creates a timestamp response or a timestamp token from a request, and prints the response/token in human-readable format. Heads up: if -token_out isn't specified, the output is always a timestamp response (TimeStampResp); if it is specified, you get a timestamp token (ContentInfo) instead.

  • -config configfile β€” the config file to use. Optional; for what the default value is, see "COMMAND SUMMARY" in openssl(1). Also check "CONFIGURATION FILE OPTIONS" for the configurable variables.
  • -section tsa_section β€” the name of the config file section holding the settings for response generation. If you don't specify one, the default TSA section gets used β€” see "CONFIGURATION FILE OPTIONS" for the deets. (Optional)
  • -queryfile request.tsq β€” the name of the file containing a DER encoded timestamp request. (Optional)
  • -passin password_src β€” specifies the password source for the TSA's private key. See the description in openssl(1). (Optional)
  • -signer tsa_cert.pem β€” the signer certificate of the TSA, in PEM format. Your TSA signing certificate must have exactly one extended key usage assigned to it: timeStamping. And that extended key usage has to be critical too β€” otherwise the certificate is literally going to be refused 😭. Overrides the signer_cert variable of the config file. (Optional)
  • -inkey filename|uri β€” the signer private key of the TSA, in PEM format. Overrides the signer_key config file option. (Optional)
  • -digest β€” the signing digest to use. Overrides the signer_digest config file option. Mandatory unless it's specified in the config file.
  • -chain certs_file.pem β€” the collection of certificates in PEM format that all get included in the response, on top of the signer certificate, if the -cert option was used for the request. This file is supposed to hold the certificate chain for the signer certificate, from its issuer upwards. Fair warning: the -reply command does not build a certificate chain automatically. (Optional)
  • -tspolicy object_id β€” the default policy to use for the response, unless the client explicitly requires a particular TSA policy. The OID can be in dotted notation or use its name. Overrides the default_policy config file option. (Optional)
  • -in response.tsr β€” specifies a previously created timestamp response, or timestamp token (if -token_in is also specified), in DER format that'll be written to the output file. This one doesn't need a request β€” it's handy when you need to examine a response's or token's content, or when you want to extract the timestamp token out of a response. And if the input is a token while the output is a timestamp response, a default 'granted' status info gets added to the token. (Optional)
  • -token_in β€” this flag works together with the -in option and tells it the input is a DER encoded timestamp token (ContentInfo) instead of a timestamp response (TimeStampResp). (Optional)
  • -out response.tsr β€” the response gets written to this file. The format and content of that file depend on other options (see -text, -token_out). Default is stdout. (Optional)
  • -token_out β€” the output is a timestamp token (ContentInfo) instead of a timestamp response (TimeStampResp). (Optional)
  • -text β€” if you specify this, the output is human-readable text format instead of DER. (Optional)
  • -engine id β€” see "Engine Options" in openssl(1). Heads up: this option is deprecated ⚠️
  • -provider name, -provider-path path, -provparam [name:]key=value, -propquery propq β€” see "Provider Options" in openssl(1), provider(7), and property(7).

πŸ¦‹ Timestamp Response verification πŸ¦‹

The -verify command checks whether a timestamp response or timestamp token is valid and actually matches a particular timestamp request or data file. Important: the -verify command does not use the configuration file. At all. ✨

  • -data file_to_hash β€” the response or token must be verified against file_to_hash. The file gets hashed with the message digest algorithm specified in the token. The -digest and -queryfile options must not be specified alongside this one. (Optional)
  • -digest digest_bytes β€” the response or token must be verified against the message digest you give here. The number of bytes must match the message digest algorithm specified in the token. The -data and -queryfile options must not be specified alongside this one. (Optional)
  • -queryfile request.tsq β€” the original timestamp request, in DER format. The -data and -digest options must not be specified alongside this one. (Optional)
  • -in response.tsr β€” the timestamp response that needs verifying, in DER format. (Mandatory)
  • -token_in β€” this flag works together with the -in option and says the input is a DER encoded timestamp token (ContentInfo) instead of a timestamp response (TimeStampResp). (Optional)
  • -untrusted files|uris β€” a set of additional untrusted certificates that might be needed while building the certificate chain for the TSA's signing certificate. These don't need to include the TSA signing certificate and intermediate CA certificates, as far as the response already includes them. (Optional)

You can give multiple sources, separated by commas and/or whitespace. Each file can hold multiple certificates.

  • -CAfile file, -CApath dir, -CAstore uri β€” see "Trusted Certificate Options" in openssl-verification-options(1) for the details. You must specify at least one of -CAfile, -CApath or -CAstore β€” no skipping this one.
  • -allow_proxy_certs, -attime, -no_check_time, -check_ss_sig, -crl_check, -crl_check_all, -explicit_policy, -extended_crl, -ignore_critical, -inhibit_any, -inhibit_map, -no_alt_chains, -partial_chain, -policy, -policy_check, -policy_print, -purpose, -suiteB_128, -suiteB_128_only, -suiteB_192, -trusted_first, -use_deltas, -auth_level, -verify_depth, -verify_email, -verify_hostname, -verify_ip, -verify_name, -x509_strict, -issuer_checks β€” set all the various options of certificate chain verification. See "Verification Options" in openssl-verification-options(1) for the details.
Any verification errors cause the command to exit, periodt πŸ’€

πŸ’– CONFIGURATION FILE OPTIONS πŸ’–

okay so bestie, here's the tea: the -query and -reply commands lowkey run on a configuration file. if you wanna know the general syntax vibes, go peek at config(5) β€” it's the whole blueprint. now, -query is chill and only uses the symbolic OID names section, and honestly it can even work without it (main character independence ✨). but -reply? -reply needs the config file. no config, no reply, periodt.

and here's a rule to tattoo on your brain 🧠: if there's a command line switch that matches a variable, the switch always overrides whatever the config file says. switch supremacy, no cap.

  • tsa section, default_tsa β€” this is the big main section, the CEO of the config. it specifies the name of another section that holds all the options for the -reply command. you can override this default section with the -section command line switch. (Optional)
  • oid_file β€” names a file with extra OBJECT IDENTIFIERS inside. each line should be the numerical form of the object identifier, then whitespace, then the short name, then whitespace, then finally the long name. (Optional)
  • oid_section β€” names a section in the config file that has extra object identifiers. each line should be the short name of the object identifier followed by = and the numerical form. heads up: the short and long names are the same when you use this option. (Optional)
  • RANDFILE β€” at startup the specified file is loaded into the random number generator, and at exit 256 bytes will be written to it. (Note: using a RANDFILE is not necessary anymore, see the "HISTORY" section below πŸ‘€)
  • serial β€” the name of the file containing the hexadecimal serial number of the last timestamp response created. this number gets incremented by 1 for each response. if the file doesn't exist at the time of response generation, a new file is created with serial number 1. (Mandatory 🚨)
  • crypto_device β€” specifies the OpenSSL engine that will be set as the default for all available algorithms. the default value is built-in, and you can specify any other engines supported by OpenSSL (e.g. use chil for the NCipher HSM). (Optional)
  • signer_cert β€” TSA signing certificate in PEM format. the same as the -signer command line option. (Optional)
  • certs β€” a file containing a set of PEM encoded certificates that need to be included in the response. the same as the -chain command line option. (Optional)
  • signer_key β€” the private key of the TSA in PEM format. the same as the -inkey command line option. (Optional)
  • signer_digest β€” signing digest to use. the same as the -digest command line option. (Mandatory unless specified on the command line 🚨)
  • default_policy β€” the default policy to use when the request doesn't mandate any policy. the same as the -tspolicy command line option. (Optional)
  • other_policies β€” comma separated list of policies that are also acceptable by the TSA, and only used if the request explicitly specifies one of them. (Optional)
  • digests β€” the list of message digest algorithms that the TSA accepts. at least one algorithm must be specified. (Mandatory 🚨)
  • accuracy β€” the accuracy of the time source of the TSA in seconds, milliseconds and microseconds. e.g. secs:1, millisecs:500, microsecs:100. if any of the components is missing, zero is assumed for that field. (Optional)
  • clock_precision_digits β€” specifies the maximum number of digits, which represent the fraction of seconds, that need to be included in the time field. the trailing zeros must be removed from the time, so there might actually be fewer digits, or no fraction of seconds at all. supported only on UNIX platforms. the maximum value is 6, default is 0. (Optional)
  • ordering β€” if this option is yes, the responses generated by this TSA can always be ordered, even if the time difference between two responses is less than the sum of their accuracies. default is no. (Optional)
  • tsa_name β€” set this option to yes if the subject name of the TSA must be included in the TSA name field of the response. default is no. (Optional)
  • ess_cert_id_chain β€” the SignedData objects created by the TSA always contain the certificate identifier of the signing certificate in a signed attribute (see RFC 2634, Enhanced Security Services). if this variable is set to no, only this signing certificate identifier is included in the SigningCertificate signed attribute. if this variable is set to yes and the certs variable or the -chain option is specified, then the certificate identifiers of the chain will also be included, where the -chain option overrides the certs variable. default is no. (Optional)
  • ess_cert_id_alg β€” this option specifies the hash function to be used to calculate the TSA's public key certificate identifier. default is sha256. (Optional)

🌈 EXAMPLES 🌈

every single example down below presumes that OPENSSL_CONF is set to a proper configuration file β€” like, the example configuration file openssl/apps/openssl.cnf will absolutely do the job, bestie. πŸ’…

πŸ¦‹ Timestamp Request

to create a timestamp request for design1.txt with SHA-256 digest, without nonce and policy, and without any requirement for a certificate in the response:

openssl ts -query -data design1.txt -no_nonce \
      -out design1.tsq

to create a similar timestamp request but specifying the message imprint explicitly:

openssl ts -query -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
       -no_nonce -out design1.tsq

to print the content of the previous request in human readable format:

openssl ts -query -in design1.tsq -text

to create a timestamp request that includes the SHA-512 digest of design2.txt, requests the signer certificate and nonce, and specifies a policy id (assuming the tsa_policy1 name is defined in the OID section of the config file):

openssl ts -query -data design2.txt -sha512 \
      -tspolicy tsa_policy1 -cert -out design2.tsq

🌸 Timestamp Response

before generating a response, a signing certificate must be created for the TSA that contains the timeStamping critical extended key usage extension without any other key usage extensions. you can add this line to the user certificate section of the config file to generate a proper certificate:

extendedKeyUsage = critical,timeStamping

see openssl-req(1), openssl-ca(1), and openssl-x509(1) for instructions. the examples below assume that cacert.pem contains the certificate of the CA, tsacert.pem is the signing certificate issued by cacert.pem, and tsakey.pem is the private key of the TSA. 🫢

to create a timestamp response for a request:

openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \
      -signer tsacert.pem -out design1.tsr

if you wanna use the settings in the config file, you could literally just write:

openssl ts -reply -queryfile design1.tsq -out design1.tsr

to print a timestamp reply to stdout in human readable format:

openssl ts -reply -in design1.tsr -text

to create a timestamp token instead of a timestamp response:

openssl ts -reply -queryfile design1.tsq -out design1_token.der -token_out

to print a timestamp token to stdout in human readable format:

openssl ts -reply -in design1_token.der -token_in -text -token_out

to extract the timestamp token from a response:

openssl ts -reply -in design1.tsr -out design1_token.der -token_out

to add 'granted' status info to a timestamp token, thereby creating a valid response:

openssl ts -reply -in design1_token.der -token_in -out design1.tsr

🧚 Timestamp Verification

to verify a timestamp reply against a request:

openssl ts -verify -queryfile design1.tsq -in design1.tsr \
      -CAfile cacert.pem -untrusted tsacert.pem

to verify a timestamp reply that includes the certificate chain:

openssl ts -verify -queryfile design2.tsq -in design2.tsr \
      -CAfile cacert.pem

to verify a timestamp token against the original data file:

openssl ts -verify -data design2.txt -in design2.tsr \
      -CAfile cacert.pem

to verify a timestamp token against a message imprint:

openssl ts -verify -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
       -in design2.tsr -CAfile cacert.pem

you could also look at the test directory for more examples. go little explorer, go πŸ¦‹βœ¨


πŸ’€ BUGS πŸ’€

ngl, this section is giving "we're working on it" and honestly? relatable. here's the full list, no sugarcoating:

  • no support for timestamps over SMTP, though it's quite easy to implement an automatic e-mail based TSA with procmail(1) and perl(1). HTTP server support is provided in the form of a separate apache module. HTTP client support is provided by tsget(1). pure TCP/IP protocol is not supported. 😭
  • the file containing the last serial number of the TSA is not locked when being read or written. this is a problem if more than one instance of openssl(1) is trying to create a timestamp response at the same time. this is not an issue when using the apache server module β€” it does proper locking. πŸ™ˆ
  • look for the FIXME word in the source files. iykyk πŸ‘€
  • the source code should really be reviewed by somebody else, too. (real.)
  • more testing is needed, I have done only some basic tests (see test/testtsa).
okay but for real bestie, if you're running multiple concurrent openssl(1) instances against the same serial file, that's the unlocked-file situation above. consider yourself warned πŸ’…

⭐ HISTORY ⭐

OpenSSL 1.1.1 introduced a new random generator (CSPRNG) with an improved seeding mechanism. the new seeding mechanism makes it unnecessary to define a RANDFILE for saving and restoring randomness β€” so that option is retained mainly for compatibility reasons, aka it's living its best legacy life. πŸŽ€

the -engine option was deprecated in OpenSSL 3.0.


πŸ‘‘ SEE ALSO πŸ‘‘

openssl(1), tsget(1), openssl-req(1), openssl-x509(1), openssl-ca(1), openssl-genrsa(1), config(5), ossl_store-file(7)

go read those too, they're all linked up in the lore 🫢✨


Copyright 2006-2025 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's a wrap, bestie 🎬✨ this was OPENSSL-TS(1ossl) from the OpenSSL source, version 3.5.6, dated 2026-04-07. timestamp slay complete, go forth and be cryptographically iconic πŸ’…πŸ‘‘πŸŒˆ

πŸ“¦ where this page comes from