Jump to content

openssl problem


conan318

Recommended Posts

Hi i have php script which i have been running on on my web server which is dreamhost which is working fine...

 

but here's  the twist i have just set-up a xampp server apache 2.2 on my windows 7 machine my website is running fine expect for the openssl encrypt script which is filing to encrypt

 

here's a sample of my code.

 

$MY_KEY_FILE = "c:\\xampp\\apache\\bin\\my-prvkey.pem";

 

# public certificate file to use

$MY_CERT_FILE = "c:\\xampp\\apache\\bin\\my-pubcert.pem";

 

# Paypal's public certificate

$PAYPAL_CERT_FILE = "c:\\xampp\\apache\\bin\\paypal_cert_pem.txt";

 

# path to the openssl binary

$OPENSSL = "c:\\xampp\\apache\\bin\\openssl.exe";

 

 

 

$form = array('cmd' => '_xclick',

        'business' => 'removed business name for security ',

        'cert_id' => 'removed cert id for security',

        'lc' => 'AU',

        'custom' => ''.$id.'',

        'invoice' => removed business name for security',

        'currency_code' => 'AUD',

        'no_shipping' => '1',

        'item_name' => 'removed business name for security',

        'item_number' => '1',

'amount' => $total

);

 

 

$encrypted = paypal_encrypt($form);

 

 

function paypal_encrypt($hash)

{

//Sample PayPal Button Encryption: Copyright 2006-2010 StellarWebSolutions.com

//Not for resale - license agreement at

//http://www.stellarwebsolutions.com/en/eula.php

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']= 'StellarWebSolutions.PHP_EWP2';

 

$data = "";

foreach ($hash as $key => $value) {

if ($value != "") {

//echo "Adding to blob: $key=$value\n";

$data .= "$key=$value\n";

}

}

// here's where i believe the problem is when creating and signing the my_cert_file i had to specify where the openssl.cnf file was do i need to do same here..

-config c:\\xampp\\apache\\bin\\openssl.cnf

 

 

$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";

 

 

}

echo $output;

 

};

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.