PHP Safari PushNotifications “Extracting push notification package failed”

安稳与你 提交于 2020-12-15 06:15:17

问题


I'm trying to implement safari notifications and I have most things figure out. I'm following the official tutorial https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/NotificationProgrammingGuideForWebsites/PushNotifications/PushNotifications.html#//apple_ref/doc/uid/TP40013225-CH3-SW1 but I'm currently receiving the error:

Extracting push notification package failed

I have seen this topic APNs "Extracting push notification package failed" but it seems the person didn't get any feedback / solution.

Before this error, I was getting "Signature verification of push package failed." but I endup solving the issue with this help Apple website push: Signature verification of push package failed, but apple certificates are ok and by downloading/converting to PEM the latest Apple certificate https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer

Website.json has the following data:

{
    "websiteName": "hello",
    "websitePushID": "web.com.hello",
    "allowedDomains": ["https://hello.com"],
    "urlFormatString": "https://hello.com/%@",
    "authenticationToken": "01sSggkfAAAqq1seeF0gglzzg",
    "webServiceURL": "https://hello.com"
}

manifest.json has the following data:

{
   "icon.iconset\/icon_16x16.png":{
      "hashType":"sha512",
      "hashValue":"d7366c75a9ad9a95ee2e6c6a4642ab6150d01986a870d8726e988c180e373cce7cbda1496150def585fb05e5b82d9753fabbe03e1e5bf56fce1c94a472bee50b"
   },
   "icon.iconset\/icon_16x16@2x.png":{
      "hashType":"sha512",
      "hashValue":"63287459ef021a8d3fe6a7ee40292446dddea305382713f25e8ff3f40b17d706012c809ebe6238a3652992ba55007f8dd22707b31f4730efc4b9d33baaca593d"
   },
   "icon.iconset\/icon_32x32.png":{
      "hashType":"sha512",
      "hashValue":"407027a704b967e57999d45ea68f2ccd156b49c698a4237ac8e60101f4c79388cbebf7242ac93c911f0176da49a49d12c5eec0f303943ea8f0d99f5d27898d21"
   },
   "icon.iconset\/icon_32x32@2x.png":{
      "hashType":"sha512",
      "hashValue":"a799fc64879d0d0304eb20b1bb96fe1c1b837e1cbc2d905ad3024b3230337d9f2a6ea41a73b02e91168b97fce13dd918f380d95ccd77ef1360e0bb818de8be99"
   },
   "icon.iconset\/icon_128x128.png":{
      "hashType":"sha512",
      "hashValue":"e709cbce5e4b4f355a4007a5665ad3b1b020ba81640fbed09db252910c20b956eab6167ae6a3e399b4b1f9ff1cf8eb4d68de844dd01a39d23fff15b3418ab6c5"
   },
   "icon.iconset\/icon_128x128@2x.png":{
      "hashType":"sha512",
      "hashValue":"1d210614b556267b6d41e1b7ad5d09db90ba77cab2196b85b7bc211873f03ebe3a89a0cf083b61181af0fa6900ba6eb8394f86e4921432a9779fb419c1def7ce"
   },
   "website.json":{
      "hashType":"sha512",
      "hashValue":"2c050ffb570fab3c4224ad2f08144f4ca9bf09d570f22bf3dc3cabf7c5146e436755bf171befcfa410d8f56ac4135b1e03b235197feed6306c5692b793b41668"
   }
}

My folder called "pushpackage" holds:

  • website.json
  • manifest.json
  • signature
  • icon.iconset folder > 6 images

Although the documentation says:

The version of the API. Currently, 'v2'

the Safari requests are being made in the endpoint https://hello.com/v1/pushPackages/web.com.hello, which is kind of strange, but..

Lastly, the POST endpoint said above, triggers:

header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="pushpackage.zip"');

echo file_get_contents($file);

The zip seems fine - at least when I open all the files are correctly structured, but I'm out of ideas about what could be wrong with the zip file. Any ideas?


回答1:


Solved.

I had several things wrong in my code.

  1. The error:

Extracting push notification package failed

Was caused due to an echo ... in the middle of the code when creating the zip file.

  1. The error:

Signature verification of push package failed

Was caused due to several factors:

  • My .p12 certificate was wrong, the .p12 Website Push ID did not match my website.json nor the javascript code. In order to debug / view the data of the certificate I used the command openssl -nokeys -info -in certificate.p12 -passin pass:
  • The certificate AppleWWDRCAG3.cer (that expires in 2030) from the oficial link https://developer.apple.com/support/expiration/ doesn't work. I had to download the file AppleWWDRCA.cer (that expires in 2023) from https://developer.apple.com/certificationauthority/AppleWWDRCA.cer
  • My icons were not created in 72dpi resolution
  • The version used by the Safari to request permissions is the version 1 "v1/pushPackages.." and I was creating the zip file with the manifest.json in the version 2


来源:https://stackoverflow.com/questions/65031632/php-safari-pushnotifications-extracting-push-notification-package-failed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!