0

tried to run the following code through a php script running locally on xampp and it returns null.I've tried running the command with exec instead of shell_exec and it returns an empty string as output. I work on Mac running mojave.

$out = shell_exec('security import ~/.bitnami/stackman/machines/xampp/volumes/root/htdocs/keys/ios.cer -k ~/Library/Keychains/app.keychain -P 123456789');

var_dump($out);

when I put the command directly into the terminal it runs successfully and it shows the following message. "1 certificate successfully imported"

I've tried putting the ios.cer file outside htdocs and again it works on terminal and not through php script.

I gave read and write permissions to everyone for the ios.cer file

exec('whoami');

the above command returns daemon. What can I try to make it run through the php script?

Evorsor
  • 21
  • 2
  • `/path/to/the/security` – AbraCadaver Apr 29 '20 at 19:09
  • But you may need to `sudo` to do it. Or `setuid` not sure about Mac. – AbraCadaver Apr 29 '20 at 19:11
  • Unlikely to be answerable without errno or stderr message. – mario Apr 29 '20 at 19:18
  • i've tried it with sudo. It still returns null. security is a commandline tool in mac. it works inside the terminal no matter what the current folder is right? – Evorsor Apr 30 '20 at 06:55
  • how do I get errno or stderr message when it only returns null when run through the php script? – Evorsor Apr 30 '20 at 06:56
  • also the post you linked is not my issue. exec function works for commands like exec('whoami') etc. its for commands that access tools like security and xcodebuild that are not working through exec(). – Evorsor Apr 30 '20 at 06:59

0 Answers0