web-push-php
web-push-php copied to clipboard
Notice: Undefined variable: tag web-push/src/Encryption.php:92
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
Setup
- Operating System: <Ubuntu 18.10>
- PHP Version: <5.6.40-8+ubuntu18.04.1+deb.sury.org+1>
- web-push-php Version: <1.3.4>
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:
- [ ] Chrome
- [x] Firefox 67.0.4
- [ ] Firefox for Mobile
- [ ] Opera for Android
- [ ] Samsung Internet Browser
- [ ] Other
Please specify the versions (i.e. Chrome Beta, Firefox Beta etc).
Problem
When i call Encryption::encrypt()
method i got:
Notice: Undefined variable: tag
On:
//vendor/minishlink/web-push/src/Encryption.php:92
} else {
$encryptedText = openssl_encrypt($payload, 'aes-128-gcm', $contentEncryptionKey, OPENSSL_RAW_DATA, $nonce, $tag); // base 64 encoded
}
Tried to work around it with setting null
as value of $nativeEncryption
but then i got 401 unauthorized response from Mozilla webpush endpoint.
Expected
Encrypted message ready to send.
Features Used
- [x] VAPID Support
- [ ] GCM API Key
- [x] Sending with Payload
Example / Reproduce Case
$encrypted = Encryption::encrypt(
$payload,
$subscription->getPublicKey(),
$subscription->getAuthToken(),
$subscription->getContentEncoding() //'aesgcm'
);
Other
Please put any remaining notes here.
PHP 5.6 don't supported AEAD encryption algorithms. The$tag
parameter was introduced in PHP 7.1.
@Spomky thanks for your reply!
For the 1.3.4
composer.json file said that it's php 5.6 compatible. So what version should I use to keep 5.6 compatibility?
@emgiezet Please read readme file (FAQ Section). You can send push but you will not be able to send any payload data with php 5.X.
You can trigger push event with this library and you can get payload data in your service worker using fetch JS method. That is the only way you can do with PHP 5.X