Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pkcs7 with timestamp

I am looking at it for a day now, and I am still baffled. I want to add digital signature to a PDF with timestamp from a TSA (TimeStamp Authority).

I am okay with sending the request to a TSA and receiving a binary response, but how do I append that timestamp to my pkcs7 digital signature.

I am using PHP with TCPDF and the openssl_pkcs7_sign() function. Do I need to to add the timestamp as an extra certificate? Thanks!

like image 876
dande Avatar asked Nov 15 '25 10:11

dande


1 Answers

I have created a simple library project called phpcmstimestamper precisely for this purpose, and you can use it like this:

<?php
$originalCmsAsPem = "-----BEGIN CMS-----
MIIFiAYJKoZIhvcNAQcCoIIFeTCCBXUCAQExDTALBglghkgBZQMEAgEwHQYJKoZI
...
1lUaWopfF7uZf5LXZt2Ru5UPr+51ULJRcEeUTA==
-----END CMS-----";
$updatedCms = CmsTimestamper::addTimestampToCms($originalCmsAsPem, "http://tsa.starfieldtech.com");

You can get more details and a fully working example at https://github.com/hablutzel1/phpcmstimestamper.

like image 60
Jaime Hablutzel Avatar answered Nov 18 '25 06:11

Jaime Hablutzel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!