fix(security): fix openssl_sign key resource in MTN initiate, add google-services.json to gitignore

This commit is contained in:
Hamza-Ayed
2026-06-17 06:55:36 +03:00
parent 1d3ea597f4
commit 75aeb73f27
3 changed files with 17 additions and 2 deletions

View File

@@ -22,7 +22,14 @@ $body = json_encode([
], JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
$hash = hash('sha256', $body, true);
openssl_sign($hash, $sig, $privateKeyPem, OPENSSL_ALGO_SHA256);
$pkey = openssl_get_privatekey($privateKeyPem);
if (!$pkey) {
error_log("[MTN Initiate] Failed to load private key");
printFailure("Payment configuration error");
exit;
}
openssl_sign($hash, $sig, $pkey, OPENSSL_ALGO_SHA256);
openssl_free_key($pkey);
$xSignature = base64_encode($sig);
$ch = curl_init("{$baseUrl}/pos_web/payment_phone/initiate");

View File

@@ -22,7 +22,14 @@ $body = json_encode([
], JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
$hash = hash('sha256', $body, true);
openssl_sign($hash, $sig, $privateKeyPem, OPENSSL_ALGO_SHA256);
$pkey = openssl_get_privatekey($privateKeyPem);
if (!$pkey) {
error_log("[MTN Initiate] Failed to load private key");
printFailure("Payment configuration error");
exit;
}
openssl_sign($hash, $sig, $pkey, OPENSSL_ALGO_SHA256);
openssl_free_key($pkey);
$xSignature = base64_encode($sig);
$ch = curl_init("{$baseUrl}/pos_web/payment_phone/initiate");