Skip to content

Commit

Permalink
Fix possible problem with CamelCased headers on PHP-FPM and/or NGINX.
Browse files Browse the repository at this point in the history
  • Loading branch information
ndeet committed Mar 4, 2022
1 parent 59bd1dd commit c7cf3e4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Gateway/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,13 @@ public function getIcon(): string {
public function processWebhook() {
if ($rawPostData = file_get_contents("php://input")) {
// Validate webhook request.
// Note: getallheaders() CamelCases all headers for PHP-FPM/Nginx but for others maybe not, so "BTCPay-Sig" may becomes "Btcpay-Sig".
$headers = getallheaders();
$signature = $headers['Btcpay-Sig'] ?? null;
foreach ($headers as $key => $value) {
if (strtolower($key) === 'btcpay-sig') {
$signature = $value;
}
}

if (!isset($signature) || !$this->apiHelper->validWebhookRequest($signature, $rawPostData)) {
Logger::debug('Failed to validate signature of webhook request.');
Expand Down

0 comments on commit c7cf3e4

Please sign in to comment.