Search code examples
phpopensslphp-openssl

OpenSSL TimeStampQuery equivalent in PHP


I'm trying to create a TimeStampQuery (tsq) to use with the Time-Stamp Protocol. In order to achieve this, I'm using the following OpenSSL terminal command:

openssl ts -query -data input_file.xml -no_nonce -sha512 -out request.tsq

Can the OpenSSL PHP extension generate Time-Stamp Queries without the need of an external executable? If so, how?


Solution

  • I finally found a feasible alternative written entirely in PHP: https://github.com/vakata/asn1

    It is designed to create and parse Abstract Syntax Notation One data structures, but comes with a specific class for generating Time-Stamp Queries which is really straight-forward to use:

    $message = "Hello World";
    $tsq = \vakata\asn1\Timestamp::generateRequestFromData($message);
    // Send TSQ to an authorized entity
    

    The documentation related to the previous method can be found here.