Closed maheshnayer closed 4 years ago
I'm having the same issue when trying to send notifications.
I have generated the key using openssl like:
I think that is throwing an error in the function getVAPIDAuthorizationHeader
in vapid.go when trying to do:
base64.RawURLEncoding.DecodeString(vapidPrivateKey)
Thanks!
@juan88 Is there a reason you are not using the webpush.GenerateVAPIDKeys()
method to generate your vapid keys?
Hi!
No there was no specific reasong why. I started with a tutorial from the mozilla's blog and I created the keys in the way I posted.
Then I created a couple of keys with the function you specified and save them to a file. That is the correct way to handle it right? I mean, the keypair generated is supposed to be reused across all the notifications that you sent.
That worked for me. So I think that is an issue with the way that the keys are encoded. If you generate the keys by any other method, the function base64.RawURLEncoding.DecodeString(vapidPrivateKey)
may throw that error since it uses a specific way to encode base64 strings. I've found out in the official docs from the package and the corresponding RFC.
in our organization's fork, we have made a change where we decode vapid keys with this method
func decodeVapidKey(key string) ([]byte, error) {
bytes, err := base64.URLEncoding.DecodeString(key)
if err == nil {
return bytes, nil
}
return base64.RawURLEncoding.DecodeString(key)
}
which solves this issue for us.
Hi I'm experiencing this error while trying to send notifications My private key has a "+" in the string and the input byte location points to this char. How can I get over this? My public key also has a "+" in it. Same issue here as well Any help appreciated Thank you