OPENSSL-TS(1ossl)
π 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:
- The TSA client computes a one-way hash value for a data file and sends the hash to the TSA.
- 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. β°β¨
- 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:
-configconfigfile β the config file to use. It's optional; for what the default value actually is, peek at "COMMAND SUMMARY" inopenssl(1).-datafile_to_hash β the data file you want the timestamp request made for. If you don't specify either-dataor-digest,stdinis the default, no cap. (Optional)-digestdigest_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 (like1A:F6:01:...or1AF601...). 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 thatopenssl-dgst(1)supports is fair game. Default isSHA-256. (Optional)-tspolicyobject_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)-inrequest.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)-outrequest.tsq β the name of the output file the request gets written to. Default isstdout. (Optional)-textβ if you specify this, the output is human-readable text format instead of DER. (Optional)-randfiles,-writerandfile β see "Random State Options" inopenssl(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.
-configconfigfile β the config file to use. Optional; for what the default value is, see "COMMAND SUMMARY" inopenssl(1). Also check "CONFIGURATION FILE OPTIONS" for the configurable variables.-sectiontsa_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)-queryfilerequest.tsq β the name of the file containing a DER encoded timestamp request. (Optional)-passinpassword_src β specifies the password source for the TSA's private key. See the description inopenssl(1). (Optional)-signertsa_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 thesigner_certvariable of the config file. (Optional)-inkeyfilename|uri β the signer private key of the TSA, in PEM format. Overrides thesigner_keyconfig file option. (Optional)-digestβ the signing digest to use. Overrides thesigner_digestconfig file option. Mandatory unless it's specified in the config file.-chaincerts_file.pem β the collection of certificates in PEM format that all get included in the response, on top of the signer certificate, if the-certoption 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-replycommand does not build a certificate chain automatically. (Optional)-tspolicyobject_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 thedefault_policyconfig file option. (Optional)-inresponse.tsr β specifies a previously created timestamp response, or timestamp token (if-token_inis 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-inoption and tells it the input is a DER encoded timestamp token (ContentInfo) instead of a timestamp response (TimeStampResp). (Optional)-outresponse.tsr β the response gets written to this file. The format and content of that file depend on other options (see-text,-token_out). Default isstdout. (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)-engineid β see "Engine Options" inopenssl(1). Heads up: this option is deprecated β οΈ-providername,-provider-pathpath,-provparam[name:]key=value,-propquerypropq β see "Provider Options" inopenssl(1),provider(7), andproperty(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. β¨
-datafile_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-digestand-queryfileoptions must not be specified alongside this one. (Optional)-digestdigest_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-dataand-queryfileoptions must not be specified alongside this one. (Optional)-queryfilerequest.tsq β the original timestamp request, in DER format. The-dataand-digestoptions must not be specified alongside this one. (Optional)-inresponse.tsr β the timestamp response that needs verifying, in DER format. (Mandatory)-token_inβ this flag works together with the-inoption and says the input is a DER encoded timestamp token (ContentInfo) instead of a timestamp response (TimeStampResp). (Optional)-untrustedfiles|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.
-CAfilefile,-CApathdir,-CAstoreuri β see "Trusted Certificate Options" inopenssl-verification-options(1)for the details. You must specify at least one of-CAfile,-CApathor-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" inopenssl-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.
tsasection,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-replycommand. you can override this default section with the-sectioncommand 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 aRANDFILEis 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 isbuilt-in, and you can specify any other engines supported by OpenSSL (e.g. usechilfor the NCipher HSM). (Optional)signer_certβ TSA signing certificate in PEM format. the same as the-signercommand 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-chaincommand line option. (Optional)signer_keyβ the private key of the TSA in PEM format. the same as the-inkeycommand line option. (Optional)signer_digestβ signing digest to use. the same as the-digestcommand 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-tspolicycommand 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 isyes, 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 isno. (Optional)tsa_nameβ set this option toyesif the subject name of the TSA must be included in the TSA name field of the response. default isno. (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 tono, only this signing certificate identifier is included in the SigningCertificate signed attribute. if this variable is set toyesand thecertsvariable or the-chainoption is specified, then the certificate identifiers of the chain will also be included, where the-chainoption overrides thecertsvariable. default isno. (Optional)ess_cert_id_algβ this option specifies the hash function to be used to calculate the TSA's public key certificate identifier. default issha256. (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)andperl(1). HTTP server support is provided in the form of a separate apache module. HTTP client support is provided bytsget(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
FIXMEword 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 π
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
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms