views:

65

answers:

1

I need to call a web service that requires a login url containing an RSA encrypted, base_64 encoded and url-encoded login data. I don't have a formal php training, but even for me it seems like an easy task, however when calling the service I get an 'Invalid Format' response. What am I doing wrong and is there another way to come up with the encrypted string? Code example below. Thank you for your help!

require 'rsa.php'; // Uses rsa.php from http://www.edsko.net/misc/ for encryption.

$message = '?id=112233&param1=hello&[email protected]&name=Name';

$keyLength = '2048';
$exponent = '65537';
$modulus = '837366556729991345239927764652........';
$encryptedData = rsa_encrypt($message, $exponent, $modulus, $keyLength);
$data = urlencode(base64_encode($encryptedData));

$loginurl = 'http://www.somedomain.com/LoginWB.aspx?Id=9876&Data='.$data;
echo '<iframe src="'.$loginurl.'" width="570px" height="800px">';
echo '</iframe>';
A: 

The encryption looks correct to me. Are you sure the server is not complaining about the '?' in the $message?

If you care about performance, you should use openssl extensions. The public key operations are very slow in PHP.

ZZ Coder
Thank you for the response. I had the same thought about the '?' in the message, and tried to remove it, but still get the same error.With openssl, it requires a certificate in "pem" format. Do you know of any way to convert a simple text key to the "pem" certificate?