2

when try to run this command from PHP it show this error

Access is denied.

$ruta = "C:\OpenSSL-Win31\bin\openssl pkcs8 -inform DER -in Usuarios_XML/$rfc/$archivo.key -out Usuarios_XML/$rfc/$archivo.key.pem -passin pass:".$key;

$ejecuta = exec($ruta . ' 2>&1', $output);
print_r($output);

But when I run it directly from my server in the openssl console it works.

I guess that I need a kind of permission but I have no idea where to change it, some idea how can achieve this?

The server is running Windows Server 2012, I hope you can help me, thanks.

Fixer
  • 175
  • 1
  • 2
  • 16
  • This would be helpful. http://stackoverflow.com/questions/17914402/php-exec-is-not-executing-the-command – Dipu Raj Nov 23 '16 at 03:35
  • @DipuRaj I read all the info from that question and is where I saw your comment but there is not information there to give the permission as you did to solve it, to which user you gave permission and how?, I really need help, I have access to my server and I can do any change but I do not what to change – Fixer Nov 23 '16 at 16:36
  • I tried to give all permission to the users and to the file, I have but it doesn't works, still the same problem, – Fixer Nov 23 '16 at 16:39

1 Answers1

0

It is a pretty complicated problem. As I understand so far, the issue is that your command is trying to access the file system and IIS is not allowed to access the file system by default. It work on command prompt becouse command propt has access to file system but when the same command run throught the PHP and WebServer(IIS) it gets denied.

You can try a few things,

  1. Go through the security properties of all the files used in the command (including C:\OpenSSL-Win31\bin\openssl.exe) and check if the NETWORK USER has access, else add it and give full access.
    To check the secuirty of the file: right click on the file > properties > security tab

  2. If that doesn't help, give IIS an Administrator access. Please check IIS: Application Pool Identities to see how to do it. Since you are giving Administrator access to IIS it has it's own risk of an outside attack. Please research more about it so you should know what your are doing.

In my case the later solution worked, let us know if any of this help you.

Dipu Raj
  • 1,784
  • 4
  • 29
  • 37
  • I tried the first one but i am not sure which is the network user of my list, I tried with the second option but it says the mostly is for windows server 2008 anyways I tried to do the part where show the W3wp.exe worker process and I tried to give full control but it doesnt let me save the changes it says `unable to save changes on w3wp, access is denied` – Fixer Nov 23 '16 at 18:00