title: Encrypting in php with Openssl on remote server and decrypting on local
body: <p>I am encrypting a string on a remote server and saving the result in a .txt file. I generated a pair of public and private keys on my local server, and transferred the public key on the remote one. Summary of logic:</p>
  
  <pre><code>$publicKey = openssl_pkey_get_public(file_get_contents('public_key.pem'));
  openssl_public_encrypt($toBeEncrypted, $encrypted, $publicKey);
  file_put_contents('result.txt', $encrypted, FILE_APPEND); 
  </code></pre>
  
  <p>If I do both encryption and decryption on my local server, it works. However, it does not work if I transfer the encrypted file from remote to local server and attempt to decrypt. I assume this is a certificate issue, but I am not sure how to fix it. I don't think I fully understand the steps and components involved between encrypting the file on the remote server and decrypting it locally. Please shed some light of what I am missing. </p>