Unfortunately, this method doesnt work.
I algo tried working with pipes:
#!/usr/bin/php -q
<?php
require_once("_cert-manage-functions.php");
//$config = parse_ini_file("/var/www/config.ini", true);
$userId = userCertId("fredfa");
// create descriptors for R/W-pipes
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
);
$proc = "openssl ca -keyfile ca.key -cert ca.pem -revoke ".$userId.".pem";
// open process with bidirectional interaction
$process = proc_open($proc, $descriptorspec, $pipes);
// if success, continue
if (is_resource($process)) {
// read until prompt
while (trim(fgets($pipes[0])) != 'Using configuration from
/usr/lib/ssl/openssl.cnf') { }
fscanf($pipes[0], "Enter pass phrase for ca.key:");
// enter pass phrase
fwrite($pipes[1], "password\n");
// read until EOF
stream_get_contents($pipes[0]);
// release resources
fclose($pipes[0]);
fclose($pipes[1]);
proc_close($process);
}
?>
...but the above doesnt work either and i still get "enter the passphrase"
prompt
2011/11/29 shiplu <[email protected]>
>
>
> On Tue, Nov 29, 2011 at 8:21 AM, asdf zxcv <[email protected]> wrote:
>
>> I'm trying to make my php script (run from console) to input nesesary data
>> when console asks for it.
>>
>> For example, i want to automatically manage revoking self-signed
>> certificates, but when i exec("command") then system asks me to give the
>> pass phrase. I dont want to do that. Instead, I want my script to input
>> the
>> password automatically.
>>
>> Is there any way to achieve that?
>>
>> Regards
>> Peter
>>
>
>
> You could try,
>
> $pass = "1285@";
> exec("echo $pass | command");
>
> But if its a privilege issue on your linux system, its better to start the
> php script with proper privilege.
>
> --
> Shiplu Mokadd.im
>
> Innovation distinguishes between follower and leader
>
>