Ask questionsAES-GCM decryption failed

NOTE: Please test in a least two browsers (i.e. Chrome and Firefox). This helps with diagnosing problems quicker.

Please confirm the following:

  • [x] I have read the README entirely
  • [x] I have verified in the issues that my problem hasn't already been resolved


Please provide the following details, the more info you can provide the better.

  • Operating System: Windows
  • PHP Version: 7.2.4
  • web-push-php Version: 4.0.2

Please check that you have installed and enabled these PHP extensions :

  • [x] gmp
  • [x] mbstring
  • [x] curl
  • [x] openssl

Please select any browsers that you are experiencing problems with:

  • [x] Chrome
  • [ ] Firefox
  • [ ] Firefox for Mobile
  • [ ] Samsung Internet Browser
  • [ ] Opera for Android
  • [ ] Other

Please specify the versions (i.e. Chrome Beta, Firefox Beta etc).

When the brower receives the push message its unable to decrypt the payload/message and therefore unable to display

Please explain what behaviour you are seeing.

To receive the message without problems

Please explain what you expected to happen

Features Used

  • [x] VAPID Support
  • [ ] GCM API Key
  • [ ] Sending with Payload

Example / Reproduce Case

Please provide a code sample that reproduces the issue. If there is a repository that reproduces the issue please put the link here.

$notifications = array(); foreach ($subscriptions as $subscription){ /** @noinspection PhpUnhandledExceptionInspection */ $notification = [ 'subscription' => Subscription::create([ 'endpoint' => $subscription->endpoint, 'publicKey' => $subscription->publicKey, // base 64 encoded, should be 88 chars 'authToken' => $subscription->authToken, // base 64 encoded, should be 24 chars 'contentEncoding' => $subscription->contentEncoding ]), 'payload' => 'hi', ]; $notifications[] = $notification; } foreach ($notifications as $notification){ try { $result = $this->webPush->sendNotification($notification['subscription'], $notification['payload'],true); var_dump($result); } catch (\ErrorException $e) { echo 'oops'; } }



Please put any remaining notes here.


Answer questions andrewiankidd

Just for the record, I encountered this because I wasn't serializing the whole subscription object, the param hint for Subscription::create suggests you only need a subsect of the fields ( endpoint, publicKey, authToken, contentEncoding)

I noticed chrome was sending a "keys" array which is parsed in Subscription::create and I was missing that, once I passed that through it started working.


Related questions

No questions were found.
Github User Rank List