title: Warning: openssl_pkcs7_sign(): error getting private key on Linux server
body: <p>Maybe this is a duplicate question and asked in <a href="https://stackoverflow.com/questions/7096877/warning-openssl-pkcs7-sign-function-openssl-pkcs7-sign-error-getting-priva">this</a> or <a href="https://stackoverflow.com/questions/32083044/warning-openssl-pkcs7-sign-error-getting-private-key-using-wamp">this</a> but this problem seems specific.</p>
  
  <p>I want to connect to a bank internet payment system that uses ssl certificates but I face this error :    </p>
  
  <pre><code>Warning: openssl_pkcs7_sign(): error getting private key in /home/zarsamco/public_html/eghtesad/ipg/enpayment.php on line 52
  </code></pre>
  
  <p>and this is the part of my code that uses certificate file (on wamp local):  </p>
  
  <pre><code>openssl_pkcs7_sign(realpath("msg.txt"), realpath("signed.txt"), "file://D:/wamp/www/zarsam/eghtesad/certs/ZarsamHonar.pem",
                  array ("file://D:/wamp/www/zarsam/eghtesad/certs/ZarsamHonar.pem", "secretPass"),
                  array (), PKCS7_NOSIGS
              );
  </code></pre>
  
  <p>it works fine in wamp on local (window 8) because the address of  <strong>ZarsamHonar.pem</strong> is absolute. However this code does not work on remote server(Linux) because i think that this way of addresses is particular for windows.  </p>
  
  <p>I tried many Addressing methods found online and the linked SO questions.<br>
  for example I try this code (<strong>enpayment.php</strong> page):  </p>
  
  <pre><code>$prepend = "file://";
  openssl_pkcs7_sign(realpath(dirname(__FILE__)) . "../msg.txt",
  realpath(dirname(__FILE__)) . "../signed.txt",
  $prepend . realpath(dirname(__FILE__)) ."/certs/ZarsamHonar.pem",
  array($prepend . realpath(dirname(__FILE__)) ."/certs/ZarsamHonar.pem", "secretPass"),array(), PKCS7_NOSIGS);
  </code></pre>
  
  <p>But it did not work out either.  </p>
  
  <p>this is a screenshot of related files structure and location of ZarsamHonar.pem , msg.txt and signed.txt files:  </p>
  
  <p><a href="https://i.stack.imgur.com/ESTgG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ESTgG.png" alt="enter image description here"></a>  </p>
  
  <p>can any one help me?</p>