fix(security): fix openssl_sign key resource in MTN initiate, add google-services.json to gitignore
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -88,6 +88,7 @@ __pycache__/
|
|||||||
venv/
|
venv/
|
||||||
|
|
||||||
# --- Firebase ---
|
# --- Firebase ---
|
||||||
|
google-services.json
|
||||||
.google-services.json
|
.google-services.json
|
||||||
GoogleService-Info.plist
|
GoogleService-Info.plist
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,14 @@ $body = json_encode([
|
|||||||
], JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
], JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
$hash = hash('sha256', $body, true);
|
$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);
|
$xSignature = base64_encode($sig);
|
||||||
|
|
||||||
$ch = curl_init("{$baseUrl}/pos_web/payment_phone/initiate");
|
$ch = curl_init("{$baseUrl}/pos_web/payment_phone/initiate");
|
||||||
|
|||||||
@@ -22,7 +22,14 @@ $body = json_encode([
|
|||||||
], JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
], JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
$hash = hash('sha256', $body, true);
|
$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);
|
$xSignature = base64_encode($sig);
|
||||||
|
|
||||||
$ch = curl_init("{$baseUrl}/pos_web/payment_phone/initiate");
|
$ch = curl_init("{$baseUrl}/pos_web/payment_phone/initiate");
|
||||||
|
|||||||
Reference in New Issue
Block a user