• Tor Lillqvist's avatar
    tdf#84881: Try to fix "The signature includes an embedded timestamp but ... · 86796f12
    Tor Lillqvist yazdı
    ... it could not be verified"
    
    I got some insight reading this question and reply on stackoverflow:
    http://stackoverflow.com/questions/18761993/steps-to-include-timestamp-in-pdf-signature
    
    I had been doing the timestamping wrong in the same way: I had timestamped the
    hash of the PDF document, not of the signature. That is wrong. If you think
    hard, it is obvious: It is the (rest of the) signature that needs an
    authenticated timestamp, not the PDF document contents. After all, if the
    document contents is timestamped, but not the signature, that doesn't prevent
    tampering with the signature after the timestamping. When you timestamp the
    signature, that proves the date of the signature. (And the signature proves
    the authenticity of the document contents.)
    
    So I had to re-engineer the code a bit. I create two originally identical NSS
    CMS messages with signatures, encode one signature into DER, take the hash of
    the signature, get a timestamp from the TSA for that hash. Then I add that
    timestamp to the other CMS message as an unsigned attribute of its signature,
    sign it, encode it, convert to hex, and store it the document.
    
    (I first tried to use just one CMS message, but NSS stopped with an assertion
    when I tried to encode the signature of the same message a second time, after
    adding the timestamp attribute to the signature. Go figure.)
    
    (I did verify the the encoded signatures, taken from what should be identical
    but separate CMS messages, was in fact identical. So I am fairly sure the idea
    described above is sound.)
    
    But, it doesn't help. Adobe Reader still complains "The signature includes an
    embedded timestamp but it could not be verified".
    
    Change-Id: I4e4cd0443005e82f597586942badc7145ef64160
    86796f12
pdfwriter_impl.cxx 490 KB