-
Notifications
You must be signed in to change notification settings - Fork 113
Crypto-Key header: illegal format #216
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
Comments
Seems to me, after a lot of struggling, that both encodings actually need to be supported at this place: URL and non-URL. |
Agreed with all the above. Just implemented this in my app and had lots of problems working out that there was a URL decoding scheme in place. Decided to go with 5.1.1 rather than 5.1.2 as could not get past the crypto-key error described above. Would be good if somebody could submit a PR. |
Switching the encoding to AES128GCM instead of AESGCM does fix the problem. I can see two reasons for that:
I can't confirm what really happened, but as per rfc8291 AESGCM is not part of the standard, whilst AES128GCM is. Therefore, i think they dropped the legacy support for AESGCM, which they probably used before the PushAPI was actually standardized. |
This issue exists since the new version 5.1.2.
What I did: Try to send a push message with VAPID, using Chrome 133.
Result: The push-service answered HTTP 403:
permission denied: crypto-key header had invalid format. crypto-key header should have the following format: p256ecdsa=base64(publicApplicationServerKey)
Reason: The error disappears when reverting the following change between version 5.1.1 and 5.1.2. in

AbstractPushService
:I checked that it can also be solved by replacing
Base64.getUrlEncoder().encodeToString(pk)
byBase64.getUrlEncoder().withoutPadding().encodeToString(pk)
.withoutPadding
was simply missed here during the task of replacingBase64Encoder
.By the way: I believe that the constructors of
Notification
that useBase64.getUrlDecoder()
andUtils.loadPublicKey
don't work because of the usage of the URL-decoder. The example in https://github.com/web-push-libs/webpush-java/wiki/Usage-Example implements the BASE64-decoding by usingBase64.getDecoder()
and notBase64.getUrlDecoder()
.The text was updated successfully, but these errors were encountered: