0

I wish to covert a .p12 file to .pem file. In Mac terminal, this command works,

openssl pkcs12 -in cert.p12 -out cert.pem -nodes -clcerts

I am using laravel 5.5

I tries using exec() but it outputs an empty file.

$p12path = storage_path($path).'/cert.p12';
$outputpem = storage_path($path).'/cert.pem';
exec('openssl pkcs12 -in ' . $p12path . ' -out '. $outputpem .' -nodes -clcerts');

Tried the above code but doesn't work.

jww
  • 97,681
  • 90
  • 411
  • 885
naz
  • 159
  • 1
  • 6

1 Answers1

0

You can use exec() function of PHP like this:

<?php
echo exec('openssl pkcs12 -in cert.p12 -out cert.pem -nodes -clcerts');
?>

exec() is used to execute an external program/command.

Amit Merchant
  • 1,045
  • 6
  • 21
  • Please consider accepting the answer as correct and also upvote if it has resolved your issue. – Amit Merchant Feb 21 '18 at 05:39
  • oops.. its not working actually... the file is not there.. im using laravel.. could it be the file path? – naz Feb 21 '18 at 07:20
  • @Naz - It sound slike the exact problem from [Convert P12 to PEM using PHP and OpenSSL](https://stackoverflow.com/q/5422205/608639). – jww Feb 21 '18 at 15:57