Discussions

Ask a Question
Back to All

Problem with signature

Hi,

I'm testing authentication but the signature generated by the code (copied and pasted from documentation):

$satispayId='vsdmp7cbe1iuki6kofe4hkmvikfpu2sdoovplk6iutdffgpht50lpt2ed2dnvm00hs82kt0j0ce312r8jl5pj86ac2sbvhbvf0shbq530hfp3q0q2rs163b709inmli7lv6fq7no4ft0jor1mvmlcoefdr3a3usobblsckbri8ea4q9db00lr6l5vghaqij2lkf9cj4g';
$bodyObject = '';
$body = json_encode($bodyObject);
echo "body:\n";
echo $body . "\n";
$digest = "SHA-256=" . base64_encode(hash("sha256", $body, true));
echo "\ndigest:\n";
echo $digest . "\n";
$date = date('r');
echo "\ndate:\n";
echo $date . "\n";
$message = "(request-target): post /g_business/v1/payments
host: staging.authservices.satispay.com
date: $date
digest: $digest";
echo "\nmessage:\n";
echo $message . "\n";
$privateKey = file_get_contents('private.pem'); // your private key
echo "\nprivate.pem:\n";
echo $privateKey . "\n";
openssl_sign($message, $signatureRaw, $privateKey, OPENSSL_ALGO_SHA256);
$signature = base64_encode($signatureRaw);
echo "\nsignature:\n";
echo $signature . "\n";
$authorization = "Signature keyId="$satispayId", algorithm="rsa-sha256", headers="(request-target) host date digest", signature="$signature"";
echo "\nauthorization:\n";
echo $authorization . "\n";

The private key in the file is correct one but when I test it (https://satispay-signature-test.glitch.me/signature) it doesen't produce the same result.

Thank you!