I sign a PDF and I add update version in which I write the DSS with its CRLs, Certs, VRI.
19 0 obj
[15 0 R 16 0 R]
endobj
20 0 obj
[13 0 R 14 0 R]
endobj
11 0 obj
[15 0 R 16 0 R]
endobj
12 0 obj
[13 0 R 14 0 R]
endobj
17 0 obj
<<
/CRL 11 0 R
/Cert 12 0 R
>>
endobj
18 0 obj
<<
/5F44CF6F351DFD45FB62F3D0ED046408BC892797 17 0 R
>>
endobj
21 0 obj
<<
/VRI 18 0 R
/CRLs 19 0 R
/Certs 20 0 R
>>
I am confused about how should I write the Certificate and CRL streams.
15 0 obj
<<
/Length 1454
/Filter /FlateDecode
>>
stream
xÚ3hb0hb{ÅÄÈhÀÉÆªÍÇÌ$ÅÊ`àcÈä2‡²° 3…Šˆ€8\¼®y%E¥Å%:žyÉz†ªÊ
ZbXd{0%KW÷ýY¯’ó‚-ØÂÛ„OÏó½z•î ‰`®•® K-›2}tÖ§^_8;xÉì¥Ó®~›.g9A'Õüê½—
ZbXd{0%KW÷ýY¯’ó‚-ØÂÛ„OÏó½z•î ‰`®•® K-›2}tÖ§^_8;xÉì¥Ó®~›.g9A'Õüê½—
endstream
endobj
16 0 obj
<<
/Length 1477
/Filter /FlateDecode
>>
stream
„kâR7Å41*!‡#8Íñ3 Ź˜@‰o=«‡çƒ#yë:X]r\~}¼)/Ñmç×£¦³äsËê]ÓÕ_+µ¥$Ô¿}¾ÜÏiÁÝT!¹ôi–Í9üÀ}Џ|
ìŒH¿GÓø^ú¿ÔVÜK–qõ†µ®“¸»Ý*Žh¾JzåU7c~÷•ÔêýK*îú®¹¸DcÁ³·NtV~Vóåíé5\‚&½|¶NäïŽ[K
î›NRZbXd{0%KW÷ýY¯’ó‚-ØÂÛ„OÏó½z•î ‰`®•® K-›2}tÖ§^_8;xÉì¥Ó®~›.g9A'Õüê½—›oÇ:ç-¶?
endstream
endobj
13 0 obj
<<
/Length 1240
/Filter /FlateDecode
>>
stream
%ŸwC[í2×¾Iej©úkŽ-:ݳÔ<¼a£ƒô/5›‡~zÒ•7ü9uãcfk?ËÅ`ßÃ:Èb—’‚Ÿõ{ÏÅ—¢{]HçQ”9w(ÂB#í×g¥ìþè
^–F«š/r§š¿ì=#,^pëO€{äú=}RÎêð¦ÉŠ7or¼±Ëtë–x·˜§LÌŒŒ‹› Cd0€eùÿ³°03±>0P ñUY$
endstream
endobj
14 0 obj
<<
/Length 1159
/Filter /FlateDecode
>>
stream
4!>T‚êPpÎI,.V0Ò™@ûœºƒ=LÍš•㈑•¹‰‘Ÿ(ÎÅÔÄÈÈplŽ÷A¯¹7k/[‡O\}
öe™¨îö£œ¶ä'¶ÌpžªweÞª[¡$¼ØÍþþtó[½xÉO4ÞZ¥ØŸ^g ø,mu„_Rz™_PÏê.||º¶*þîÝxv½"»êôó»ø%Ü%ý
endstream
endobj
Please ignore the lengths and content of the streams above. I truncated them so the lengths don't correspond anymore. The streams are bigger than that.
The issue is that my PDF is not LTV enabled and I tested some scenarios from which I concluded that my stream are not being written the right way.
I use the following structure from WinCrypt.h:
typedef struct _CERT_CONTEXT {
DWORD dwCertEncodingType;
BYTE *pbCertEncoded;
DWORD cbCertEncoded;
PCERT_INFO pCertInfo;
HCERTSTORE hCertStore;
} CERT_CONTEXT, *PCERT_CONTEXT;
typedef const CERT_CONTEXT *PCCERT_CONTEXT;
I go through them and get the bytes this way:
PCCERT_CONTEXT cngContext = (PCCERT_CONTEXT)(*itChain);
ByteArray certBytes(cngContext->pbCertEncoded, (size_t)cngContext->cbCertEncoded);
Then I just apply FlateDecode on the obtained bytes and write them into the PDF like a stream as you can see in the second block of code.
Am I missing any step? Like a conversion or something? I saw that the stream should be BER-Encoded. So should I transform the bytes into BER-Encoded and then apply FlateDecode?
Edit:
You can find My File here