Skip to content

Signing a PDF does not work - Pkcs12Handler #7667

@pgarsk

Description

@pgarsk

Describe the bug

Signing a PDF does not work. An error occurs after trying to sign.

To reproduce

I have completely uninstalled, reinstalled LibreSign, checked the dependencies and regenerated all certificates. Still, the signing process errors out.

Internal Server Error

The server was unable to complete your request.
If this happens again, please send the technical details below to the server administrator.
Technical details:

Remote Address: 172.#######
Request ID: fgG####7A5zv######
Message: OCA\Libresign\Handler\SignEngine\Pkcs12Handler::extractTimestampData(): Argument #1 ($decoded) must be of type array, null given, called in /var/www/html/custom_apps/libresign/lib/Handler/SignEngine/Pkcs12Handler.php on line 121

Expected behavior

No response

Screenshots

No response

Environment information

--------- ------------------- -------------------------------------------------------------------------------------------------------------- ------------------------------------------ 
  Status    Resource            Message                                                                                                        Tip                                       
 --------- ------------------- -------------------------------------------------------------------------------------------------------------- ------------------------------------------ 
   info     java                Non-UTF-8 encoding detected: ANSI_X3.4-1968. This may cause issues with accented or special characters         Java detected encoding "ANSI_X3.4-1968"   
                                                                                                                                               but UTF-8 is required.                    
                                                                                                                                                                                         
                                                                                                                                               **Current PHP environment:**              
                                                                                                                                               - LC_CTYPE: C.UTF-8                       
                                                                                                                                               - LC_ALL: not set                         
                                                                                                                                               - LANG: not set                           
                                                                                                                                                                                         
                                                                                                                                               **To fix this issue:**                    
                                                                                                                                               1. Set LC_ALL and LANG environment        
                                                                                                                                               variables (e.g., LC_ALL=en_US.UTF-8) for  
                                                                                                                                               your web server user                      
                                                                                                                                               2. Restart your web server after making   
                                                                                                                                               changes                                   
                                                                                                                                               3. Verify with command: `locale charmap`  
                                                                                                                                               (should return UTF-8)                     
                                                                                                                                                                                         
                                                                                                                                               For more details, see: [Issue             
                                                                                                                                               #4872](https://github.com/LibreSign/libr  
                                                                                                                                               esign/issues/4872)                        
  success   pdftk               PDFtk version: 3.3.3                                                                                                                                     
  success   pdftk               PDFtk path: /var/www/html/data/appdata_ocknz0sk89v7/libresign/x86_64/pdftk/pdftk.jar                                                                     
  success   jsignpdf            JSignPdf version: 2.3.0                                                                                                                                  
  success   jsignpdf            JSignPdf path: /var/www/html/data/appdata_ocknz0sk89v7/libresign/x86_64/jsignpdf/jsignpdf-2.3.0/JSignPdf.jar                                             
   info     pdfsig              Poppler utils not installed                                                                                    Install the package poppler-utils at      
                                                                                                                                               your operational system to be possible    
                                                                                                                                               get more details about validation of      
                                                                                                                                               signatures.                               
   info     pdfinfo             Poppler utils not installed                                                                                    Install the package poppler-utils at      
                                                                                                                                               your operational system have a fallback   
                                                                                                                                               to fetch page dimensions.                 
  success   openssl-configure   Root certificate setup is working fine.                                                                                                                  
 --------- ------------------- -------------------------------------------------------------------------------------------------------------- ------------------------------------------ 
scriptName":"/ocs/v2.php","message":"OCA\\Libresign\\Handler\\SignEngine\\Pkcs12Handler::extractTimestampData(): Argument #1 ($decoded) must be of type array, null given, called in /var/www/html/custom_apps/libresign/lib/Handler/SignEngine/Pkcs12Handler.php on line 121","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:149.0) Gecko/20100101 Firefox/149.0","version":"33.0.0.16","exception":{"Exception":"TypeError","Message":"OCA\\Libresign\\Handler\\SignEngine\\Pkcs12Handler::extractTimestampData(): Argument #1 ($decoded) must be of type array, null given, called in /var/www/html/custom_apps/libresign/lib/Handler/SignEngine/Pkcs12Handler.php on line 121","Code":0,"Trace":[{"file":"/var/www/html/custom_apps/libresign/lib/Handler/SignEngine/Pkcs12Handler.php","line":121,"function":"extractTimestampData","class":"OCA\\Libresign\\Handler\\SignEngine\\Pkcs12Handler","type":"->","args":[null,[]]},{"file":"/var/www/html/custom_apps/libresign/lib/Handler/SignEngine/Pkcs12Handler.php","line":101,"function":"processSignature","class":"OCA\\Libresign\\Handler\\SignEngine\\Pkcs12Handler","type":"->","args":[null,null]},{"file":"/var/www/html/custom_apps/libresign/lib/Handler/SignEngine/SignEngineHandler.php","line":229,"function":"getCertificateChain","class":"OCA\\Libresign\\Handler\\SignEngine\\Pkcs12Handler","type":"->","args":[null]},{"file":"/var/www/html/custom_apps/libresign/lib/Service/SignFileService.php","line":630,"function":"getLastSignedDate","class":"OCA\\Libresign\\Handler\\SignEngine\\SignEngineHandler","type":"->","args":[]},{"file":"/var/www/html/custom_apps/libresign/lib/Service/SignFileService.php","line":442,"function":"signSequentially","class":"OCA\\Libresign\\Service\\SignFileService","type":"->","args":[[{"file":{"__class__":"OCA\\Libresign\\Db\\File","id":19},"signRequest":{"__class__":"OCA\\Libresign\\Db\\SignRequest","id":19}}]]},{"file":"/var/www/html/custom_apps/libresign/lib/Service/SignFileService.php","line":435,"function":"executeSigningStrategy","class":"OCA\\Libresign\\Service\\SignFileService","type":"->","args":[[{"file":{"__class__":"OCA\\Libresign\\Db\\File","id":19},"signRequest":{"__class__":"OCA\\Libresign\\Db\\SignRequest","id":19}}]]},{"file":"/var/www/html/custom_apps/libresign/lib/Controller/SignFileController.php","line":224,"function":"sign","class":"OCA\\Libresign\\Service\\SignFileService","type":"->","args":[]},{"file":"/var/www/html/custom_apps/libresign/lib/Controller/SignFileController.php","line":165,"function":"signSync","class":"OCA\\Libresign\\Controller\\SignFileController","type":"->","args":[{"__class__":"OCA\\Libresign\\Db\\File","id":19},[{"documentElementId":16,"profileNodeId":1211},{"documentElementId":17,"profileNodeId":1211},{"documentElementId":18,"profileNodeId":1211},{"documentElementId":19,"profileNodeId":1211},{"documentElementId":20,"profileNodeId":1211}],{"user-agent":"Mozilla/5.0 (X11; Linux x86_64; rv:149.0) Gecko/20100101 Firefox/149.0","remote-address":"172.18.0.11"}]},{"file":"/var/www/html/custom_apps/libresign/lib/Controller/SignFileController.php","line":112,"function":"sign","class":"OCA\\Libresign\\Controller\\SignFileController","type":"->","args":["password",[{"documentElementId":16,"profileNodeId":1211},{"documentElementId":17,"profileNodeId":1211},{"documentElementId":18,"profileNodeId":1211},{"documentElementId":19,"profileNodeId":1211},{"documentElementId":20,"profileNodeId":1211}],"","GDrq98x9L@g^TXed4J0I",null,"4724fbd6-9da3-4699-9df9-49b99f9c8320",true]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":205,"function":"signUsingUuid","class":"OCA\\Libresign\\Controller\\SignFileController","type":"->","args":["4724fbd6-9da3-4699-9df9-49b99f9c8320","password",[{"documentElementId":16,"profileNodeId":1211},{"documentElementId":17,"profileNodeId":1211},{"documentElementId":18,"profileNodeId":1211},{"documentElementId":19,"profileNodeId":1211},{"documentElementId":20,"profileNodeId":1211}],"","GDrq98x9L@g^TXed4J0I",true]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":118,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Libresign\\Controller\\SignFileController"},"signUsingUuid"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":153,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Libresign\\Controller\\SignFileController"},"signUsingUuid"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":321,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Libresign\\Controller\\SignFileController","signUsingUuid",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"_route":"ocs.libresign.signfile.signusinguuid","apiVersion":"v1","uuid":"4724fbd6-9da3-4699-9df9-49b99f9c8320"}]},{"file":"/var/www/html/ocs/v1.php","line":61,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/ocsapp/apps/libresign/api/v1/sign/uuid/4724fbd6-9da3-4699-9df9-49b99f9c8320"]},{"file":"/var/www/html/ocs/v2.php","line":8,"args":["/var/www/html/ocs/v1.php"],"function":"require_once"}],"File":"/var/www/html/custom_apps/libresign/lib/Handler/SignEngine/Pkcs12Handler.php","Line":165,"message":"OCA\\Libresign\\Handler\\SignEngine\\Pkcs12Handler::extractTimestampData(): Argument #1 ($decoded) must be of type array, null given, called in /var/www/html/custom_apps/libresign/lib/Handler/SignEngine/Pkcs12Handler.php on line 121","exception":"{\"class\":\"TypeError\",\"message\":\"OCA\\Libresign\\Handler\\SignEngine\\Pkcs12Handler::extractTimestampData(): Argument #1 ($decoded) must be of type array, null given, called in /var/www/html/custom_apps/libresign/lib/Handler/SignEngine/Pkcs12Handler.php on line 121\",\"code\":0,\"file\":\"/var/www/html/custom_apps/libresign/lib/Handler/SignEngine/Pkcs12Handler.php:165\",\"trace\":\"#0 /var/www/html/custom_apps/libresign/lib/Handler/SignEngine/Pkcs12Handler.php(121): OCA\\Libresign\\Handler\\SignEngine\\Pkcs12Handler->extractTimestampData(NULL, Array)\\n#1 /var/www/html/custom_apps/libresign/lib/Handler/SignEngine/Pkcs12Handler.php(101): OCA\\Libresign\\Handler\\SignEngine\\Pkcs12Handler->processSignature(Resource id #152, '\\xFE\\xFF\\x00T\\x00i\\x00t\\x00e\\x00l')\\n#2 /var/www/html/custom_apps/libresign/lib/Handler/SignEngine/SignEngineHandler.php(229): OCA\\Libresign\\Handler\\SignEngine\\Pkcs12Handler->getCertificateChain(Resource id #152)\\n#3 /var/www/html/custom_apps/libresign/lib/Service/SignFileService.php(630): OCA\\Libresign\\Handler\\SignEngine\\SignEngineHandler->getLastSignedDate()\\n#4 /var/www/html/custom_apps/libresign/lib/Service/SignFileService.php(442): OCA\\Libresign\\Service\\SignFileService->signSequentially(Array)\\n#5 /var/www/html/custom_apps/libresign/lib/Service/SignFileService.php(435): OCA\\Libresign\\Service\\SignFileService->executeSigningStrategy(Array)\\n#6 /var/www/html/custom_apps/libresign/lib/Controller/SignFileController.php(224): OCA\\Libresign\\Service\\SignFileService->sign()\\n#7 /var/www/html/custom_apps/libresign/lib/Controller/SignFileController.php(165): OCA\\Libresign\\Controller\\SignFileController->signSync(Object(OCA\\Libresign\\Db\\File), Array, Array)\\n#8 /var/www/html/custom_apps/libresign/lib/Controller/SignFileController.php(112): OCA\\Libresign\\Controller\\SignFileController->sign('password', Array, '', '################', NULL, '##############...', true)\\n#9 /var/www/html/lib/private/AppFramework/Http/Dispatcher.php(205): OCA\\Libresign\\Controller\\SignFileController->signUsingUuid('4724fbd6-9da3-4...', 'password', Array, '', 'GDrq98x9L@g^TXe...', true)\\n#10 /var/www/html/lib/private/AppFramework/Http/Dispatcher.php(118): OC\\AppFramework\\Http\\Dispatcher->executeController(Object(OCA\\Libresign\\Controller\\SignFileController), 'signUsingUuid')\\n#11 /var/www/html/lib/private/AppFramework/App.php(153): OC\\AppFramework\\Http\\Dispatcher->dispatch(Object(OCA\\Libresign\\Controller\\SignFileController), 'signUsingUuid')\\n#12 /var/www/html/lib/private/Route/Router.php(321): OC\\AppFramework\\App::main('OCA\\\\Libresign\\\\C...', 'signUsingUuid', Object(OC\\AppFramework\\DependencyInjection\\DIContainer), Array)\\n#13 /var/www/html/ocs/v1.php(61): OC\\Route\\Router->match('/ocsapp/apps/li...')\\n#14 /var/www/html/ocs/v2.php(8): require_once('/var/www/html/o...')\\n#15 {main}\"}","CustomMessage":"OCA\\Libresign\\Handler\\SignEngine\\Pkcs12Handler::extractTimestampData(): Argument #1 ($decoded) must be of type array, null given, called in /var/www/html/custom_apps/libresign/lib/Handler/SignEngine/Pkcs12Handler.php on line 121"}}

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    0. Needs triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions