title: openssl_pkcs7_sign(): error getting private key
body: <p>When trying to use TCPDF to generate a pdf and sign it, i get the error:</p>
  
  <pre><code>openssl_pkcs7_sign(): error getting private key.
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>Undefined offset: 1 in ..\tcpdf\tcpdf.php on line 7604
  </code></pre>
  
  <p>I have found the following stackoverflow posts and tried to follow their solutions:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/32083044/warning-openssl-pkcs7-sign-error-getting-private-key-using-wamp">Warning: openssl_pkcs7_sign(): error getting private key using WAMP</a></li>
  <li><a href="https://stackoverflow.com/questions/7096877/warning-openssl-pkcs7-sign-function-openssl-pkcs7-sign-error-getting-priva">Warning: openssl_pkcs7_sign() [function.openssl-pkcs7-sign]: error getting private key in C:\xampp\htdocs\this\tcpdf\tcpdf.php on line 8366</a></li>
  </ul>
  
  <p>Unfortunately, nothing works.</p>
  
  <p>I have tried to use:</p>
  
  <pre><code>$certificate = "file://" . getcwd() . "/objects/dummy_cert.cert";
  </code></pre>
  
  <p>or</p>
  
  <pre><code>$certificate = "file://" . __DIR__ "/objects/dummy_cert.cert";
  </code></pre>
  
  <p>or writing the absolute path by hand.</p>
  
  <p>My script is executed from the project root path, from which <code>/objects/</code> is the next folder in which my <code>dummy_cert.cert</code> lies.</p>
  
  <p>What is happening here and how can i fix this?</p>
  
  <p>I even logged the content of $certificate to be sure it generates the correct path. The generated path, copied into Google Chrome address bar, immediately loads the content of the .cert file.</p>