title: how to digitally sign a file in PHP
body: <p>I made a <strong>user</strong> table in my DB with different columns for holding users' info. Also I have added two columns <strong>public_key</strong> and <strong>private_key</strong>.
  When a user registers, his info will be inserted to the table. plus I am using:</p>
  
  <pre><code>// Create the keypair
  $res=openssl_pkey_new();
  
  // Get private key
  openssl_pkey_export($res, $privatekey);
  
  // Get public key
  $publickey=openssl_pkey_get_details($res);
  $publickey=$publickey["key"];
  </code></pre>
  
  <p>to create a random key pair and give it to user so that every user has a key pair.
  I want my users to have digital-signature ability, so when they upload a file they sign it.</p>
  
  <p>I decided to sign a sample file(msg.txt) first to see if I can and then proceed. It looks straight forward:</p>
  
  <pre><code>openssl_pkcs7_sign("msg.txt", "signed.txt", "signing_cert.pem",
  array("private_key.pem", "mypassphrase"),
  array()
  );
  </code></pre>
  
  <p>The problem is: what are signing_cert.pem and private_key.pem ? I pasted my generated public key in signing_cert.pem and the private one in private_key.pem, but I see this error: </p>
  
  <pre><code>Warning: openssl_pkcs7_sign() [function.openssl-pkcs7-sign]: error getting 
  private key in /home/ofathian/public_html/msc/ebook/mine/assymetric-test.php 
  on line 40
  </code></pre>
  
  <p>Any opinion is appreciated.</p>