Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime exception with Mdanter ECC library #14

Closed
kanishkdudeja opened this issue May 8, 2016 · 7 comments
Closed

Runtime exception with Mdanter ECC library #14

kanishkdudeja opened this issue May 8, 2016 · 7 comments

Comments

@kanishkdudeja
Copy link

'https://android.googleapis.com/gcm/send/dpGMEh3K2cg:APA91bGrPuUlu9b-WPngdR9b0IXyw2cC7PZJ8u3-5VU21P6nhwSlvw9MSk8omOIzZeMLOcqxrjO-rEEAKZAeMNdF6VQMHIcz-m8ZeemgqwI-LraL9M0D37L2RjzYRiYxhvqotfVSRJS1', // Chrome 'payload' => 'Hello', 'userPublicKey' => 'BCXxO8IhPp_PVjnfx7TugJA3gYdQd3jZUzfcinsjiLjtCL_uJf_2Y9fK8HYkAp2ot6FXs5q7ZFOzdiNlttThpdA=', 'userAuthToken' => 'gMDKYYtTeHKG-8nGKN1xzQ==', ) ); $apiKeys = array( 'GCM' => 'AIzaSyDoqTxHy2cw2bxLAE7lwTrImgzKyfZJKaQ', ); $webPush = new WebPush($apiKeys); // send multiple notifications with payload foreach ($notifications as $notification) { $webPush->sendNotification( $notification['endpoint'], $notification['payload'], // optional (defaults null) $notification['userPublicKey'], // optional (defaults null) $notification['userAuthToken'] // optional (defaults null) ); } $webPush->flush(); ?>

I get this output:

PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Curve curve(-3, 41058363725152142129326129780047268409114441015993725554835256314039467401291, 115792089210356248762697446949407573530086143415290314195533631308867097853951) does not contain point (67038273347490662382185575485487379440402771158004031264493575046428765755, 116935489649439228016838975285237332447812780727018558127038228236318709568)' in /var/www/vendor/mdanter/ecc/src/Primitives/Point.php:100
Stack trace:
#0 /var/www/vendor/mdanter/ecc/src/Primitives/CurveFp.php(111): Mdanter\Ecc\Primitives\Point->__construct(Object(Mdanter\Ecc\Math\Gmp), Object(Mdanter\Ecc\Curves\NamedCurveFp), '670382733474906...', '116935489649439...', NULL)
#1 /var/www/vendor/mdanter/ecc/src/Serializer/Point/UncompressedPointSerializer.php(76): Mdanter\Ecc\Primitives\CurveFp->getPoint('670382733474906...', '116935489649439...')
#2 /var/www/vendor/minish in /var/www/vendor/mdanter/ecc/src/Primitives/Point.php on line 100

Not sure if this is an issue with this library or the ECC library.

@ghost
Copy link

ghost commented May 8, 2016

@kanishkdudeja yeah me too. Tried more than 15+ tokens and their corresponding keys etc didn't get a result. Then switched to google's node.js library and it worked.

@web-lee
Copy link

web-lee commented May 9, 2016

Yep, same here. I keep getting:

Fatal error: Uncaught exception 'RuntimeException' with message 'Curve curve(-3, 41058363725152142129326129780047268409114441015993725554835256314039467401291, 115792089210356248762697446949407573530086143415290314195533631308867097853951) does not contain point (4918410515761654444245044766134315055690937175350732461240884756267261219282, 6958983596947047513192093070725538977923166797291921065363057851985837714368)' in....

@Minishlink
Copy link
Member

Hi,

Please look at the other open issues before creating a new one. This is the same as #12 and should be resolved by #13, but you can fix this already by correctly using the regular base 64 encoding (MIME spec) instead of the URL-safe variant.
BCXxO8IhPp_PVjnfx7TugJA3gYdQd3jZUzfcinsjiLjtCL_uJf_2Y9fK8HYkAp2ot6FXs5q7ZFOzdiNlttThpdA= is clearly Base64 URL safe encoded and so does your auth tokens.

@akhilesh-kk2
Copy link

akhilesh-kk2 commented Mar 14, 2018

Hi Minishlink,
I am using https://github.com/Minishlink/web-push-php-example to send push using VAPID.
In 50% cases above code is working fine but in other 50% cases i am getting error. Please find error message below.

Fatal error: Uncaught exception 'RuntimeException' with message 'Curve curve(-3, 41058363725152142129326129780047268409114441015993725554835256314039467401291, 115792089210356248762697446949407573530086143415290314195533631308867097853951) does not contain point (3241839770838454464458762781498604280851602814305279715423694631606457933959, 5171447275398088959133285509003806382170852108135282320327383382674674072772)' in C:\xxxxxxxxx\vendor\mdanter\ecc\src\Primitives\Point.php on line 100

I am using you latest branch from git.
My src/Encryption.php file already using
$userPublicKey = Base64Url::decode($userPublicKey);
$userAuthToken = Base64Url::decode($userAuthToken);

Please find 2 endpoint, key and token below that is throwing error.

==============1st============
'https://fcm.googleapis.com/fcm/send/cpzPHMsiSA0:APA91bEGvnuuYdJXZ3ZBMaDV7xyTm4m4lvWdovaqDCW_-tZokZtiU4ieqJKDuRshbngHYDI_P4NDesbNOPp77q125PzJxH8BrQ2g3kw5pOMZe-tSE_0UnJr6O2d6otgxbtwLzOa574P1',

'BHK tD4LOUcd3K5fmRhMeNiRy22MZrObmqVh1BYxssgh7bu94ayrgR0gP4Vf92HZk6r/sSUxcMY8ErMjws7i8xI=',

'5536inU7PxmfxdshX2DnNQ==',

==============2nd============
'https://fcm.googleapis.com/fcm/send/fiOncCrPinU:APA91bFwNavvta0ZvzuWREmM4FKZ7fT5halVyxOXJ7Z8WuaQeU11fnjwKW_mCTLD754NOXNPyAeV3hjn6iKwWFTWZvt15TYTCy0kd9-XNLYnIF5Lq4dVTE-PVMK4TkItEbq9-sEwpb2J',

'BDtWy4HfhkfyXAJnP51PLsldXvRI8Gyj2OGDQbklvUCFBNBpyU/nJg0ytb4enzQc5DoLIGqllKeFLRpNDvvirgA=',

'F WPP1RQd/nfoDOss rEHQ=='

@akhilesh-kk2
Copy link

Hi Spomky,
Your solution is "Closing as it looks like the issue came from a double encoding.", But at what point double encoding is happening ( Link : phpecc/phpecc#235)?
If double encoding is the issue, then why i am getting this issue in 50% cases?

@Minishlink
Copy link
Member

Hello @akhilesh-kk2, can you try with v4 (or v3)? If the problem is still there please open a new issue (I totally forgot you commented on this one)

@akhilesh-kk2
Copy link

Hello Minishlink,
I tried to send push using V4, but code throwing new error messages. Please find error message below.

1) Warning: hex2bin(): Hexadecimal input string must have an even length in C:\Users\Admin\Dropbox\phpws\web-push-php-example\vendor\minishlink\web-push\src\Utils.php on line 60

2) Warning: hex2bin(): Hexadecimal input string must have an even length in C:\Users\Admin\Dropbox\phpws\web-push-php-example\vendor\minishlink\web-push\src\Utils.php on line 61

3) Fatal error: Uncaught TypeError: bin2hex() expects parameter 1 to be string, boolean given in C:\Users\Admin\Dropbox\phpws\web-push-php-example\vendor\minishlink\web-push\src\Encryption.php on line 94

4) TypeError: bin2hex() expects parameter 1 to be string, boolean given in C:\Users\Admin\Dropbox\phpws\web-push-php-example\vendor\minishlink\web-push\src\Encryption.php on line 94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants