1

I have a PHP script which needs to point to my server openssl directory but am lost. I know the directory resides at /usr/bin/openssl while my site pages rest at /var/www/vhosts/domain/httpdocs/test.php.

Within test.php, I try to call the openssl directory using relative paths at /usr/bin/openssl but I know this is causing an issue. Can anybody help?

PHP script which is trying to call openssl for certificate encryption:

<?php 

//earlier in the file $operatingos was set to true or false based on the OS.
if(!$operatingos) {

#PRIVATE KEY FILE $MY_KEY_FILE = "my-prvkey.pem"; #PUBLIC KEY FILE $MY_CERT_FILE = "my-pubcert.pem"; #PAYPAL PUBLIC CERTIFICATE if(!$testingservices) { $PAYPAL_CERT_FILE = "paypal_cert.pem"; //LIVE } else { $PAYPAL_CERT_FILE = "paypal_cert_sandbox.pem"; //SANDBOX } #PATH TO OPENSSL BINARY $OPENSSL = "/usr/bin/openssl"; 

} else {

#PRIVATE KEY FILE $MY_KEY_FILE = "C:\\xampp\\htdocs\\privkey.pem"; #PUBLIC KEY FILE $MY_CERT_FILE = "C:\\xampp\\htdocs\\pubcert.pempem"; #PAYPAL PUBLIC CERTIFICATE if(!$testingservices) { $PAYPAL_CERT_FILE = "C:\\xampp\\htdocs\\pppubcert.pem"; } else { $PAYPAL_CERT_FILE = "C:\\xampp\\htdocs\\pppubcert_sandbox.pem"; } #PATH TO OPENSSL BINARY $OPENSSL = "C:\\OpenSSL-Win32\\bin\\openssl.exe"; 

}

$form = array('cmd' => '_xclick', 'business' => 'email', 'cert_id' => 'certid', 'lc' => 'US', 'custom' => 'test', 'invoice' => '', 'currency_code' => 'USD', 'no_shipping' => '1', 'item_name' => 'Donation', 'item_number' => '1', 'amount' => '10' ); $encrypted = paypal_encrypt($form); function paypal_encrypt($hash) { global $MY_KEY_FILE; global $MY_CERT_FILE; global $PAYPAL_CERT_FILE; global $OPENSSL; if (!file_exists($MY_KEY_FILE)) { echo "ERROR: MY_KEY_FILE $MY_KEY_FILE not found\n"; } if (!file_exists($MY_CERT_FILE)) { echo "ERROR: MY_CERT_FILE $MY_CERT_FILE not found\n"; } if (!file_exists($PAYPAL_CERT_FILE)) { echo "ERROR: PAYPAL_CERT_FILE $PAYPAL_CERT_FILE not found\n"; } //Assign Build Notation for PayPal Support $hash['bn']= 'domain.PHP_EWP2'; $data = ""; foreach ($hash as $key => $value) { if ($value != "") { //echo "Adding to blob: $key=$value\n"; $data .= "$key=$value\n"; } } $openssl_cmd = "($OPENSSL smime -sign -signer $MY_CERT_FILE -inkey $MY_KEY_FILE " . "-outform der -nodetach -binary <<_EOF_\n$data\n_EOF_\n) | " . "$OPENSSL smime -encrypt -des3 -binary -outform pem $PAYPAL_CERT_FILE"; exec($openssl_cmd, $output, $error); if (!$error) { return implode("\n",$output); } else { return "ERROR: encryption failed"; } }; ?> 
4
  • Are you trying to include a script? Not sure what it is you're trying to do. Commented Jul 13, 2010 at 18:31
  • I am trying to call my openssl directory within PHP Commented Jul 13, 2010 at 19:10
  • Is PHP in safe mode? Commented Jul 13, 2010 at 19:20
  • @industro - no it is not Commented Jul 13, 2010 at 19:22

1 Answer 1

1

The issue laid in the way the directory structures differ between a Windows and Linux system. Quite dumb on my part but the double slashes in a windows directory were required

2
  • can you show the fixed code? I am not sure exactly how to fix mine... Commented Nov 4, 2011 at 6:16
  • @RRR not sure I follow entirely but I've update the code somewhat to give you a better idea. Commented Dec 7, 2011 at 21:21

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.