gauntface / web-push-go

Apache License 2.0
99 stars 14 forks source link

Base64 decoding problem of auth and p256dh #24

Open juan88 opened 6 years ago

juan88 commented 6 years ago

Hello.

I've been having some problems with some p256dh values and some auths that seem to have been created by the javascript end of the web push app that do not have a terminating "=" or "==" respectively.

The function used in the examples, base64.URLEncoding.DecodeString complains that there is invalid data in the input when trying to process the encoded string.

Any ideas of what this might be?

anaskhan96 commented 6 years ago

This is because base64.URLEncoding.DecodeString expects padded base64 encoded strings (terminating with an "=" or "==") as input. Try using base64.RawURLEncoding.DecodeString for unpadded values.