Forum Moderators: phranque

Message Too Old, No Replies

unable to access openssl

         

iambic9

3:57 pm on Feb 15, 2010 (gmt 0)

10+ Year Member



Hi, I'm trying to access openssl with a php function to encrypt a simple file, I'm writing errors to a log and simply receiving the following:

sh: /openssl: No such file or directory


I'm really struggling to work this one out, I have an identical app running on a couple of different shared servers / hosts without any problems, but in this case it's a dedicated server and I will admit that I'm really out of my depth here, what I could really use is a couple of pointers on where and how to troubleshoot this because I just don't know where to even start looking, and I'm obviously doing something wrong or not at all.

ENVIRONMENT:

• FastCGI enabled
• PHP is running as domainuser
• PHP Version 5.2.6
• Apache 2.2.3 / CentOS 5.3 / Plesk 8.6.0

NOTES:

• phpinfo() reports:
– •
 Configure Command: --with-openssl

– •
 OpenSSL support: enabled

– •
 OpenSSL Version: OpenSSL 0.9.8b


• Since PHP is running as domainuser, I couldn't access
/var/lib/php/session/
until I ran
chown -R domainuser:psacln
, could user permissions also be why I can't use openssl?
• I had a peek in
/usr/bin
and openssl is in there.
• There's no SSL cert for the server but is that even relevant?

I've spent the weekend reading as much as I can on Apache, OpenSSL, Centos, I even went back over the manuals at PHP.net on OpenSSL and
proc_open
to see if there were any pointers, I've even read every post here on openssl – everything seems so broad, I need to narrow it down a bit, I'm under a lot of pressure to get this working and I'm not sure where to start trying to troubleshoot this specific issue, the server is practically a default install, do I need to add or change anything in Config files to make openssl work? Maybe it's not accessble from PHP running as a cgi?

Any hints, logs to check, config files or values I should check, manuals I should read or tests I could perform would be really appreciated!


FUNCTION:


function saveOrder($an_order)
{
global $config_openssl_path;
global $config_orders_path;

$descriptorspec = array(
0 => array("pipe", "r"),// stdin is a pipe that the child will read from
1 => array("pipe", "w"),// stdout is a pipe that the child will write to
2 => array("file", $config_orders_path."/error.txt", "a") // stderr is a file to write to
);

$order_data = $an_order->outputOrderFile();
$order_name = $config_orders_path.time()."".(rand()%1000);
$cwd = getcwd()."/";
$pem_in_file = $cwd.$config_orders_path."/public.pem";
$key_out_file = $cwd.$order_name.".key";
$data_out_file = $cwd.$order_name.".dat";

$encryptionPassword = generateRandomPassword(22);

//encrypt the password with public.pem
$encryptCommand = $config_openssl_path." rsautl -encrypt -inkey ".$pem_in_file." -pubin -out ".$key_out_file;
$process = proc_open($encryptCommand, $descriptorspec, $pipes);
$error = true;
if( is_resource($process) ){
fwrite($pipes[0], "$encryptionPassword\n");
fclose($pipes[0]);
fclose($pipes[1]);

$return_value = proc_close($process);

if( $return_value == 0 ){
// encrypt the data
$encryptCommand = $config_openssl_path." des3 -salt -pass pass:".$encryptionPassword." -out ".$data_out_file;

$process = proc_open($encryptCommand, $descriptorspec, $pipes);
if( is_resource($process) ){
fwrite($pipes[0], $order_data);
fclose($pipes[0]);
fclose($pipes[1]);

$return_value = proc_close($process);
}
}
}
}

iambic9

5:08 pm on Feb 15, 2010 (gmt 0)

10+ Year Member



[SOLVED] I can't edit the above post, but it turns out our PLESK installation is buggy and keeps re-enabling
safe_mode
, even when I switch it off, and even when it reports that it is not enabled for the domain. C'est la vie, the reading has done me good. I do not like PLESK.