title: Is it possible to convert .cer and a .key files to .pem by only using php openssl functions?
body: <p>I already have converted a public key (.cer) and a private key (.key) to pem format but I had use the command lines to convert them as follows:</p>
  
  <pre><code>$openSSLpath = "c:\OpenSSL-Win64\bin\openssl.exe";   //Path to OpenSSL exe
  $path = "c:\appserver\Apache2.2\htdocs\FIEL";        //Path to Project Folder
  $rutaCer = $path.'\GAMA600504JP1.cer';
  $rutaKey = $path.'\GAMA600504JP1.key';
  $passwordKey = '12345678a';
  
  $cmdKey = $openSSLpath." pkcs8 -inform DER -in ".$rutaKey." -passin pass:".$passwordKey." -out ".$rutaKey.".pem";
  exec($cmdKey);
  
  $cmdCer = $openSSLpath." x509 -inform DER -outform PEM -in ".$rutaCer." -pubkey -out ".$rutaCer.".pem";
  exec($cmdCer);
  </code></pre>
  
  <p>This generates correctly the .pem files but I need to know if is it possible to do this by any other way using PHP. Note that I'm completely new to openSSL and this is the only way I've found to do it on PHP.</p>
  
  <p>To do this I have to ensure that OpenSSL its properly located and installed on my server and in order to do the conversions to .pem I have to save the .cer and .key files temporarily in the server which its not recommended due to security reasons.</p>
  
  <p>Is there any other way?</p>