Hi,

thanks for your hints.
The problem was, that it tries using RC4. If i compiled PoDoFo with
#define PODOFO_HAVE_OPENSSL_NO_RC4
it runs through. (how to fix this? i have the static lib of OpenSSL included)

The problem now is, that i cannot open the PDF with the password „owner“:

            encrypt = PdfEncrypt::CreatePdfEncrypt("", "owner", 0, 
PdfEncrypt::ePdfEncryptAlgorithm_AESV2, PdfEncrypt::ePdfKeyLength_128);

            try {
                doc1.SetEncrypted(*encrypt);
            }
            catch (const PdfError eCode) {
                error = eCode.GetError();
            }

            try {
                doc1.Write(outPath->GetCStringPtr());
            }
            catch (const PdfError eCode) {
                error = eCode.GetError();
            }

If i open the PDF, the password „owner“ is wrong. It cannot be decrypted. 
Anything wrong?
--

Grüße/Regards,
[heubach-media] | Christian Sakowski
christian.sakow...@heubach-media.de
Tel: +49/(0)40/41 455 455



> Am 27.01.2022 um 18:36 schrieb zyx <z...@gmx.us>:
> 
> On Thu, 2022-01-27 at 16:04 +0100, Christian Sakowski wrote:
>> Hi,
>> 
>> i am using 0.9.7. However, i have activated OpenSSL and now i am
>> getting ePdfError_InternalLogic while writing an encrypted pdf file:
>> 
>> PoDoFo::PdfMemDocument doc1;
>> 
>> doc1.Load(inPath);
>> doc1.SetEncrypted(pass1, pass2);
>> doc1.Write(outPath); //-> ePdfError_InternalLogic
> 
>       Hi,
> does it print any detailed error on the console? A backtrace of the
> exception? Anything than the generic "it doesn't work" will help to
> diagnose. You can search the source code and see where and why it
> failed, if the detailed error is not useful.
> 
> I do not have any test code for this, my only code creates a mem
> document, then sets the encryption on it and only then draws to the
> document and writes it to the stream. Something like (this is
> inefficient, only a test code from a distant past):
> 
>   PdfEncrypt *encrypt;
>   encrypt = PdfEncrypt::CreatePdfEncrypt("", "owner", 0, algo, keyLength);
>   PdfMemDocument *memDocument = new PdfMemDocument();
>   memDocument->SetEncrypted(*encrypt);
>   delete encrypt;
>   drawPage(memDocument);
>   memDocument->Write(....);
>   delete memDocument;
> 
> I think it should work to encrypt existing document, thus I guess you
> maybe picked an unsupported algorithm or something like that. The pairs
> for 'algo' and 'keyLength' from the above I used are:
> 
>   PdfEncrypt::ePdfEncryptAlgorithm_RC4V1, PdfEncrypt::ePdfKeyLength_40
>   PdfEncrypt::ePdfEncryptAlgorithm_RC4V2, PdfEncrypt::ePdfKeyLength_128
>   PdfEncrypt::ePdfEncryptAlgorithm_AESV2, PdfEncrypt::ePdfKeyLength_128
>   PdfEncrypt::ePdfEncryptAlgorithm_AESV3, PdfEncrypt::ePdfKeyLength_256
> 
> where some can fail due to being disabled in the OpenSSL due to being
> considered insecure.
> 
>       Bye,
>       zyx
> 
> 
> _______________________________________________
> Podofo-users mailing list
> Podofo-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/podofo-users




_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to